Menu

[r13166]: / branches / release-17.12 / src / plugins / debuggergdb / debuggerdriver.cpp  Maximize  Restore  History

Download this file

200 lines (167 with data), 4.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
* This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
* http://www.gnu.org/licenses/gpl-3.0.html
*
* $Revision$
* $Id$
* $HeadURL$
*/
#include <sdk.h>
#include "debuggerdriver.h"
#include "debuggergdb.h"
#include <cbdebugger_interfaces.h>
DebuggerDriver::DebuggerDriver(DebuggerGDB* plugin)
: m_pDBG(plugin),
m_ProgramIsStopped(true),
m_ChildPID(0),
m_QueueBusy(false),
m_currentFrameNo(0),
m_userSelectedFrameNo(-1)
{
//ctor
}
DebuggerDriver::~DebuggerDriver()
{
//dtor
for (size_t ii = 0; ii < m_DCmds.GetCount(); ++ii)
delete m_DCmds[ii];
m_DCmds.Clear();
}
void DebuggerDriver::Log(const wxString& msg)
{
m_pDBG->Log(msg);
}
void DebuggerDriver::DebugLog(const wxString& msg)
{
m_pDBG->DebugLog(msg);
}
void DebuggerDriver::ClearDirectories()
{
m_Dirs.Clear();
}
void DebuggerDriver::AddDirectory(const wxString& dir)
{
if (m_Dirs.Index(dir) == wxNOT_FOUND)
m_Dirs.Add(dir);
}
void DebuggerDriver::SetWorkingDirectory(const wxString& dir)
{
m_WorkingDir = dir;
}
wxString DebuggerDriver::GetDebuggersWorkingDirectory() const
{
wxString oldDir = wxGetCwd();
wxSetWorkingDirectory(m_WorkingDir);
wxString newDir = wxGetCwd();
wxSetWorkingDirectory(oldDir);
return newDir;
}
void DebuggerDriver::SetArguments(const wxString& args)
{
m_Args = args;
}
void DebuggerDriver::ShowFile(const wxString& file, int line)
{
wxCommandEvent event(DEBUGGER_SHOW_FILE_LINE);
event.SetString(file);
event.SetInt(line);
m_pDBG->ProcessEvent(event);
}
void DebuggerDriver::NotifyCursorChanged()
{
if (!m_Cursor.changed || m_LastCursorAddress == m_Cursor.address)
return;
m_LastCursorAddress = m_Cursor.address;
wxCommandEvent event(DEBUGGER_CURSOR_CHANGED);
m_pDBG->ProcessEvent(event);
}
void DebuggerDriver::NotifyDebuggeeContinued()
{
m_pDBG->DebuggeeContinued();
ResetCursor();
}
void DebuggerDriver::ResetCursor()
{
m_LastCursorAddress.Clear();
m_Cursor.address.Clear();
m_Cursor.file.Clear();
m_Cursor.function.Clear();
m_Cursor.line = -1;
m_Cursor.changed = false;
}
void DebuggerDriver::QueueCommand(DebuggerCmd* dcmd, QueuePriority prio)
{
// DebugLog(_T("Queueing command: ") + dcmd->m_Cmd);
if (prio == Low)
m_DCmds.Add(dcmd);
else
m_DCmds.Insert(dcmd, 0);
RunQueue();
}
DebuggerCmd* DebuggerDriver::CurrentCommand()
{
return m_DCmds.GetCount() ? m_DCmds[0] : 0;
}
void DebuggerDriver::RunQueue()
{
if (m_QueueBusy || !m_DCmds.GetCount() || !IsProgramStopped())
return;
DebuggerCmd *command = CurrentCommand();
// Log(_T("Running command: ") + CurrentCommand()->m_Cmd);
// don't send a command if empty; most debuggers repeat the last command this way...
if (!command->m_Cmd.IsEmpty())
{
m_QueueBusy = true;
m_pDBG->DoSendCommand(command->m_Cmd);
if (command->IsContinueCommand())
m_ProgramIsStopped = false;
}
// Call Action()
command->Action();
// If the command was an action (i.e. no command specified,
// remove it from the queue and run the next command.
// For other commands, this happens in driver's ParseOutput().
if (command->m_Cmd.IsEmpty())
{
RemoveTopCommand(true);
RunQueue();
}
}
void DebuggerDriver::RemoveTopCommand(bool deleteIt)
{
if (m_QueueBusy || !m_DCmds.GetCount())
return;
// Log(_T("Removing command: ") + CurrentCommand()->m_Cmd);
if (deleteIt)
delete m_DCmds[0];
m_DCmds.RemoveAt(0);
}
DebuggerDriver::StackFrameContainer const & DebuggerDriver::GetStackFrames() const
{
return m_backtrace;
}
DebuggerDriver::StackFrameContainer& DebuggerDriver::GetStackFrames()
{
return m_backtrace;
}
const DebuggerDriver::ThreadsContainer & DebuggerDriver::GetThreads() const
{
return m_threads;
}
DebuggerDriver::ThreadsContainer & DebuggerDriver::GetThreads()
{
return m_threads;
}
void DebuggerDriver::SetCurrentFrame(int number, bool user_selected)
{
m_currentFrameNo = number;
if (user_selected)
m_userSelectedFrameNo = number;
}
void DebuggerDriver::ResetCurrentFrame()
{
m_currentFrameNo = 0;
m_userSelectedFrameNo = -1;
if (Manager::Get()->GetDebuggerManager()->UpdateBacktrace())
Manager::Get()->GetDebuggerManager()->GetBacktraceDialog()->Reload();
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.