• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdevelop API Reference
  • KDE Home
  • Contact Us
 

kdevplatform/debugger

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • debugger
  • interfaces
idebugsession.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * This file is part of KDevelop *
3  * Copyright 2009 Niko Sams <[email protected]> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU Library General Public License as *
7  * published by the Free Software Foundation; either version 2 of the *
8  * License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Library General Public *
16  * License along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #include "idebugsession.h"
22 #include "iframestackmodel.h"
23 #include "ivariablecontroller.h"
24 #include <debug.h>
25 
26 #include <QFileInfo>
27 
28 
29 namespace KDevelop {
30 
31 class IDebugSessionPrivate
32 {
33 public:
34  explicit IDebugSessionPrivate(IDebugSession* q) : q(q) {}
35 
36  void slotStateChanged(IDebugSession::DebuggerState state);
37 
38  IDebugSession* q;
39 
41  QUrl m_url;
42  int m_line;
43  QString m_addr;
44 };
45 
46 IDebugSession::IDebugSession()
47  : d_ptr(new IDebugSessionPrivate(this))
48 {
49  connect(this, &IDebugSession::stateChanged,
50  this, [this](IDebugSession::DebuggerState state) { Q_D(IDebugSession); d->slotStateChanged(state); });
51 }
52 
53 IDebugSession::~IDebugSession()
54 {
55 }
56 
57 bool IDebugSession::isRunning() const
58 {
59  DebuggerState s = state();
60  return (s == ActiveState || s == PausedState);
61 }
62 
63 void IDebugSession::raiseEvent(event_t e)
64 {
65  if (IFrameStackModel* model = frameStackModel()) {
66  model->handleEvent(e);
67  }
68  if (IVariableController* variables = variableController()) {
69  variables->handleEvent(e);
70  }
71  // FIXME: consider if we actually need signals
72  emit event(e);
73 }
74 
75 QPair<QUrl, int> IDebugSession::convertToLocalUrl(const QPair<QUrl, int> &remoteUrl) const
76 {
77  return remoteUrl;
78 }
79 
80 QPair<QUrl, int> IDebugSession::convertToRemoteUrl(const QPair<QUrl, int>& localUrl) const
81 {
82  return localUrl;
83 }
84 
85 void IDebugSession::clearCurrentPosition()
86 {
87  Q_D(IDebugSession);
88 
89  qCDebug(DEBUGGER);
90  d->m_url.clear();
91  d->m_addr.clear();
92  d->m_line = -1;
93  emit clearExecutionPoint();
94 }
95 
96 void IDebugSession::setCurrentPosition(const QUrl& url, int line, const QString& addr)
97 {
98  Q_D(IDebugSession);
99 
100  qCDebug(DEBUGGER) << url << line << addr;
101 
102  if (url.isEmpty() || !QFileInfo::exists(convertToLocalUrl(qMakePair(url,line)).first.path())) {
103  clearCurrentPosition();
104  d->m_addr = addr;
105  emit showStepInDisassemble(addr);
106  } else {
107  d->m_url = url;
108  d->m_line = line;
109  d->m_addr = addr;
110  emit showStepInSource(url, line, addr);
111  }
112 }
113 
114 QUrl IDebugSession::currentUrl() const
115 {
116  Q_D(const IDebugSession);
117 
118  return d->m_url;
119 }
120 
121 int IDebugSession::currentLine() const
122 {
123  Q_D(const IDebugSession);
124 
125  return d->m_line;
126 }
127 
128 QString IDebugSession::currentAddr() const
129 {
130  Q_D(const IDebugSession);
131 
132  return d->m_addr;
133 }
134 
135 void IDebugSessionPrivate::slotStateChanged(IDebugSession::DebuggerState state)
136 {
137  if (state != IDebugSession::PausedState) {
138  q->clearCurrentPosition();
139  }
140 }
141 
142 }
143 
144 #include "moc_idebugsession.cpp"
KDevelop::IDebugSession::event
void event(IDebugSession::event_t e)
This signal is emitted whenever the given event in a program happens.
KDevelop::IDebugSession::~IDebugSession
~IDebugSession() override
Definition: idebugsession.cpp:70
KDevelop::IDebugSession::IDebugSession
IDebugSession()
Definition: idebugsession.cpp:63
KDevelop::IDebugSession::setCurrentPosition
void setCurrentPosition(const QUrl &url, int line, const QString &addr)
Sets new position and emits showStepInSource or showStepInDisassemble (if source file is unavailable)...
Definition: idebugsession.cpp:113
QUrl
KDevelop::IDebugSession::showStepInDisassemble
void showStepInDisassemble(const QString &addr)
KDevelop::IDebugSession::currentLine
int currentLine() const
Definition: idebugsession.cpp:138
KDevelop::IDebugSession::PausedState
Definition: idebugsession.h:65
KDevelop::IDebugSession::variableController
virtual IVariableController * variableController() const =0
QFileInfo::exists
bool exists() const
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KDevelop::IDebugSession::showStepInSource
void showStepInSource(const QUrl &file, int line, const QString &addr)
QUrl::isEmpty
bool isEmpty() const
KDevelop::IDebugSession::raiseEvent
virtual void raiseEvent(event_t e)
Raises the specified event.
Definition: idebugsession.cpp:80
QString
KDevelop::IDebugSession::clearCurrentPosition
void clearCurrentPosition()
Definition: idebugsession.cpp:102
KDevelop::IDebugSession::frameStackModel
virtual IFrameStackModel * frameStackModel() const =0
KDevelop::IDebugSession
Definition: idebugsession.h:54
ivariablecontroller.h
idebugsession.h
iframestackmodel.h
KDevelop::IDebugSession::currentAddr
QString currentAddr() const
Definition: idebugsession.cpp:145
KDevelop::IDebugSession::event_t
event_t
Definition: idebugsession.h:72
KDevelop::IDebugSession::convertToLocalUrl
virtual QPair< QUrl, int > convertToLocalUrl(const QPair< QUrl, int > &remoteUrl) const
Returns the local Url for a source file used in the current debug session.
Definition: idebugsession.cpp:92
KDevelop::IDebugSession::ActiveState
Definition: idebugsession.h:64
KDevelop
The variables widget is passive, and is invoked by the rest of the code via two main Q_SLOTS:
Definition: breakpoint.h:34
KDevelop::IDebugSession::convertToRemoteUrl
virtual QPair< QUrl, int > convertToRemoteUrl(const QPair< QUrl, int > &localUrl) const
Returns the remote Url for a source file used in the current debug session.
Definition: idebugsession.cpp:97
KDevelop::IVariableController
Definition: ivariablecontroller.h:41
KDevelop::IDebugSession::state
virtual DebuggerState state() const =0
Current state of the debug session.
KDevelop::IDebugSession::currentUrl
QUrl currentUrl() const
Definition: idebugsession.cpp:131
KDevelop::IDebugSession::clearExecutionPoint
void clearExecutionPoint()
KDevelop::IDebugSession::isRunning
bool isRunning() const
Returns if the debugee is currently running.
Definition: idebugsession.cpp:74
QPair
KDevelop::IFrameStackModel
Definition: iframestackmodel.h:50
KDevelop::IDebugSession::DebuggerState
DebuggerState
Definition: idebugsession.h:61
KDevelop::IDebugSession::stateChanged
void stateChanged(KDevelop::IDebugSession::DebuggerState state)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 16 2021 23:29:37 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/debugger

Skip menu "kdevplatform/debugger"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal