Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Debugger/pull candidate/memory range watch/1 #8

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/include/cbplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ class PLUGIN_EXPORT cbDebuggerPlugin: public cbPlugin

// watches
virtual cb::shared_ptr<cbWatch> AddWatch(const wxString& symbol) = 0;
virtual cb::shared_ptr<cbWatch> AddMemoryRange(uint64_t address, uint64_t size, const wxString &id ) = 0;
virtual void DeleteWatch(cb::shared_ptr<cbWatch> watch) = 0;
virtual bool HasWatch(cb::shared_ptr<cbWatch> watch) = 0;
virtual void ShowWatchProperties(cb::shared_ptr<cbWatch> watch) = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/include/sdk_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ extern EVTIMPORT const wxEventType cbEVT_DEBUGGER_STARTED;
#define EVT_DEBUGGER_STARTED(fn) DECLARE_EVENT_TABLE_ENTRY( cbEVT_DEBUGGER_STARTED, -1, -1, (wxObjectEventFunction)(wxEventFunction)(CodeBlocksEventFunction)&fn, (wxObject *) NULL ),
extern EVTIMPORT const wxEventType cbEVT_DEBUGGER_PAUSED;
#define EVT_DEBUGGER_PAUSED(fn) DECLARE_EVENT_TABLE_ENTRY( cbEVT_DEBUGGER_PAUSED, -1, -1, (wxObjectEventFunction)(wxEventFunction)(CodeBlocksEventFunction)&fn, (wxObject *) NULL ),
extern EVTIMPORT const wxEventType cbEVT_DEBUGGER_CONTINUED;
#define cbEVT_DEBUGGER_CONTINUED(fn) DECLARE_EVENT_TABLE_ENTRY( cbEVT_DEBUGGER_CONTINUED, -1, -1, (wxObjectEventFunction)(wxEventFunction)(CodeBlocksEventFunction)&fn, (wxObject *) NULL ),
extern EVTIMPORT const wxEventType cbEVT_DEBUGGER_FINISHED;
#define EVT_DEBUGGER_FINISHED(fn) DECLARE_EVENT_TABLE_ENTRY( cbEVT_DEBUGGER_FINISHED, -1, -1, (wxObjectEventFunction)(wxEventFunction)(CodeBlocksEventFunction)&fn, (wxObject *) NULL ),

Expand Down
25 changes: 25 additions & 0 deletions src/plugins/debuggergdb/cdb_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ void CDB_driver::SetVarValue(cb_unused const wxString& var, cb_unused const wxSt
NOT_IMPLEMENTED();
}

void CDB_driver::SetMemoryRangeValue(uint64_t addr, const wxString& value)
{
NOT_IMPLEMENTED();
}

void CDB_driver::MemoryDump()
{
NOT_IMPLEMENTED();
Expand Down Expand Up @@ -322,6 +327,18 @@ void CDB_driver::Attach(cb_unused int pid)
// FIXME (obfuscated#): implement this
}

void CDB_driver::UpdateMemoryRangeWatches(MemoryRangeWatchesContainer &watches)
{
// FIXME (bluehazzard#): implement this
NOT_IMPLEMENTED();
}

void CDB_driver::UpdateMemoryRangeWatch(const cb::shared_ptr<GDBMemoryRangeWatch> &watch)
{
// FIXME (bluehazzard#): implement this
NOT_IMPLEMENTED();
}

void CDB_driver::Detach()
{
QueueCommand(new CdbCmd_Detach(this));
Expand Down Expand Up @@ -409,6 +426,14 @@ void CDB_driver::ParseOutput(const wxString& output)
if (notifyChange)
NotifyCursorChanged();

if(m_ProgramIsStopped)
{
// Notify debugger plugins for pause of debug session
PluginManager *plm = Manager::Get()->GetPluginManager();
CodeBlocksEvent evt(cbEVT_DEBUGGER_PAUSED);
plm->NotifyPlugins(evt);
}

buffer.Clear();
}

Expand Down
3 changes: 3 additions & 0 deletions src/plugins/debuggergdb/cdb_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class CDB_driver : public DebuggerDriver
virtual void CPURegisters();
virtual void SwitchToFrame(size_t number);
virtual void SetVarValue(const wxString& var, const wxString& value);
virtual void SetMemoryRangeValue(uint64_t addr, const wxString& value);
virtual void MemoryDump();
virtual void Attach(int pid);
virtual void Detach();
Expand All @@ -56,6 +57,8 @@ class CDB_driver : public DebuggerDriver
virtual void UpdateWatches(cb::shared_ptr<GDBWatch> localsWatch, cb::shared_ptr<GDBWatch> funcArgsWatch,
WatchesContainer &watches);
virtual void UpdateWatch(cb::shared_ptr<GDBWatch> const &watch);
virtual void UpdateMemoryRangeWatches(MemoryRangeWatchesContainer &watches);
virtual void UpdateMemoryRangeWatch(const cb::shared_ptr<GDBMemoryRangeWatch> &watch);
virtual void UpdateWatchLocalsArgs(cb::shared_ptr<GDBWatch> const &watch, bool locals);
virtual void ParseOutput(const wxString& output);
virtual bool IsDebuggingStarted() const;
Expand Down
31 changes: 31 additions & 0 deletions src/plugins/debuggergdb/debugger_defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
#include "debuggerdriver.h"

#include <wx/arrimpl.cpp>
#include <cinttypes>

#if !defined(CB_TEST_PROJECT)

const int DEBUGGER_CURSOR_CHANGED = wxNewId();
const int DEBUGGER_SHOW_FILE_LINE = wxNewId();

const wxString GDBMemoryRangeWatch::emptyString = wxEmptyString;

DebuggerCmd::DebuggerCmd(DebuggerDriver* driver, const wxString& cmd, bool logToNormalLog)
: m_Cmd(cmd),
m_pDriver(driver),
Expand Down Expand Up @@ -306,6 +309,34 @@ bool GDBWatch::GetForTooltip() const
return m_forTooltip;
}

GDBMemoryRangeWatch::GDBMemoryRangeWatch(uint64_t address, uint64_t size, const wxString& name)
{
m_address = address;
m_size = size;
m_name = name;
};

bool GDBMemoryRangeWatch::SetValue(const wxString &value)
{
if (m_value != value)
{
m_value = value;
MarkAsChanged(true);
}
return true;
}

wxString GDBMemoryRangeWatch::MakeSymbolToAddress() const
{
const int tmpBuffSize = 20;
char tmpAddress[tmpBuffSize];

memset(tmpAddress, 0, tmpBuffSize);
snprintf(tmpAddress, tmpBuffSize, "0x%" PRIx64 " ", GetAddress());

return wxString::FromUTF8(tmpAddress);
};

bool IsPointerType(wxString type)
{
type.Trim(true);
Expand Down
35 changes: 34 additions & 1 deletion src/plugins/debuggergdb/debugger_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,42 @@ class GDBWatch : public cbWatch
int m_array_count;
bool m_is_array;
bool m_forTooltip;
};
};

class GDBMemoryRangeWatch : public cbWatch
{
public:
GDBMemoryRangeWatch(uint64_t address, uint64_t size, const wxString& name);

virtual ~GDBMemoryRangeWatch() {};
public:
virtual void GetSymbol(wxString &symbol) const { symbol = m_name; };
virtual void GetValue(wxString &value) const { value = m_value; };
virtual bool SetValue(const wxString &value);
virtual void GetFullWatchString(wxString &full_watch) const { full_watch = wxEmptyString; };
virtual void GetType(wxString &type) const { type = wxT("Memory range"); };
virtual void SetType(const wxString &type) { };

virtual wxString const & GetDebugString() const { return emptyString; };

wxString MakeSymbolToAddress() const override;
bool IsPointerType() const override { return false; };

uint64_t GetAddress() const {return m_address;};
uint64_t GetSize() const {return m_size;};


private:
uint64_t m_address;
uint64_t m_size;
wxString m_name;
wxString m_value;

static const wxString emptyString;
};

typedef std::vector<cb::shared_ptr<GDBWatch> > WatchesContainer;
typedef std::vector<cb::shared_ptr<GDBMemoryRangeWatch> > MemoryRangeWatchesContainer;

bool IsPointerType(wxString type);
wxString CleanStringValue(wxString value);
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/debuggergdb/debuggerdriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class DebuggerDriver
virtual void CPURegisters() = 0;
virtual void SwitchToFrame(size_t number) = 0;
virtual void SetVarValue(const wxString& var, const wxString& value) = 0;
virtual void SetMemoryRangeValue(uint64_t addr, const wxString& value) = 0;
virtual void MemoryDump() = 0;
virtual void RunningThreads() = 0;

Expand Down Expand Up @@ -143,6 +144,9 @@ class DebuggerDriver
virtual void UpdateWatch(cb::shared_ptr<GDBWatch> const &watch) = 0;
virtual void UpdateWatchLocalsArgs(cb::shared_ptr<GDBWatch> const &watch, bool locals) = 0;

virtual void UpdateMemoryRangeWatches(MemoryRangeWatchesContainer &watches) = 0;
virtual void UpdateMemoryRangeWatch(const cb::shared_ptr<GDBMemoryRangeWatch> &watch) = 0;

/** Attach to process */
virtual void Attach(int pid) = 0;
/** Detach from running process. */
Expand Down
Loading