Skip to content

Commit

Permalink
LLDB debugger: clicking on an entry in the 'Callstack' selects that f…
Browse files Browse the repository at this point in the history
…rame
  • Loading branch information
eranif committed Apr 15, 2014
1 parent f0a9e1b commit 4b6349c
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 11 deletions.
9 changes: 9 additions & 0 deletions LLDBDebugger/LLDBCallStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "LLDBProtocol/LLDBEvent.h"
#include "LLDBProtocol/LLDBConnector.h"
#include <wx/wupdlock.h>
#include "macros.h"

LLDBCallStackPane::LLDBCallStackPane(wxWindow* parent, LLDBConnector* connector)
: LLDBCallStackBase(parent)
Expand Down Expand Up @@ -40,3 +41,11 @@ void LLDBCallStackPane::OnRunning(LLDBEvent& event)
event.Skip();
m_dvListCtrlBacktrace->DeleteAllItems();
}

void LLDBCallStackPane::OnItemActivated(wxDataViewEvent& event)
{
// Activate the selected frame
CHECK_ITEM_RET(event.GetItem());
int rowNum = m_dvListCtrlBacktrace->ItemToRow( event.GetItem() );
m_connector->SelectFrame( rowNum );
}
1 change: 1 addition & 0 deletions LLDBDebugger/LLDBCallStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class LLDBCallStackPane : public LLDBCallStackBase
{
LLDBConnector* m_connector;
protected:
virtual void OnItemActivated(wxDataViewEvent& event);
void OnBacktrace(LLDBEvent &event);
void OnRunning(LLDBEvent &event);

Expand Down
2 changes: 2 additions & 0 deletions LLDBDebugger/LLDBProtocol/LLDBCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void LLDBCommand::FromJSON(const JSONElement& json)
m_interruptReason = json.namedObject("m_interruptReason").toInt(kInterruptReasonNone);
m_lldbId = json.namedObject("m_lldbId").toInt(wxNOT_FOUND);
m_env = json.namedObject("m_env").toStringMap();
m_frameId = json.namedObject("m_frameId").toInt(wxNOT_FOUND);

JSONElement arr = json.namedObject("m_breakpoints");
for(int i=0; i<arr.arraySize(); ++i) {
Expand All @@ -45,6 +46,7 @@ JSONElement LLDBCommand::ToJSON() const
json.addProperty("m_interruptReason", m_interruptReason);
json.addProperty("m_lldbId", m_lldbId);
json.addProperty("m_env", m_env);
json.addProperty("m_frameId", m_frameId);

JSONElement bparr = JSONElement::createArray("m_breakpoints");
json.append( bparr );
Expand Down
16 changes: 12 additions & 4 deletions LLDBDebugger/LLDBProtocol/LLDBCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class LLDBCommand
int m_interruptReason;
int m_lldbId;
JSONElement::wxStringMap_t m_env;
LLDBSettings m_settings;
LLDBSettings m_settings;
int m_frameId;

public:
// Serialization API
Expand All @@ -29,16 +30,17 @@ class LLDBCommand
LLDBCommand() : m_commandType(kCommandInvalid), m_interruptReason(kInterruptReasonNone), m_lldbId(0) {}
LLDBCommand(const wxString &jsonString);
virtual ~LLDBCommand();

void FillEnvFromMemory();
/**
* @brief return an environment array
* The environment array is allocated on the heap and should be deleted
* The environment array is allocated on the heap and should be deleted
* by the caller
*/
char **GetEnvArray() const;

void Clear() {
m_frameId = wxNOT_FOUND;
m_env.clear();
m_commandType = kCommandInvalid;
m_commandArguments.clear();
Expand All @@ -50,6 +52,12 @@ class LLDBCommand
m_lldbId = wxNOT_FOUND;
}

void SetFrameId(int frameId) {
this->m_frameId = frameId;
}
int GetFrameId() const {
return m_frameId;
}
void SetEnv(const JSONElement::wxStringMap_t& env) {
this->m_env = env;
}
Expand Down
10 changes: 10 additions & 0 deletions LLDBDebugger/LLDBProtocol/LLDBConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,16 @@ wxString LLDBConnector::GetDebugServerPath() const
return path;
}

void LLDBConnector::SelectFrame(int frameID)
{
if ( IsCanInteract() ) {
LLDBCommand command;
command.SetCommandType( kCommandSelectFrame );
command.SetFrameId( frameID );
SendCommand( command );
}
}


void LLDBTerminalCallback::OnProcessOutput(const wxString& str)
{
Expand Down
5 changes: 5 additions & 0 deletions LLDBDebugger/LLDBProtocol/LLDBConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ class LLDBConnector : public wxEvtHandler
* @param reason
*/
void Interrupt(eInterruptReason reason);

/**
* @brief select a given frame
*/
void SelectFrame(int frameID);
};

#endif // LLDBCONNECTOR_H
1 change: 1 addition & 0 deletions LLDBDebugger/LLDBProtocol/LLDBEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum eCommandType {
kCommandInterrupt,
kCommandGetLocals,
kCommandExpandVariable,
kCommandSelectFrame,
};

enum eLLDBOptions {
Expand Down
2 changes: 1 addition & 1 deletion LLDBDebugger/LLDBProtocol/LLDBSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static const wxString s_DefaultTypes =

LLDBSettings::LLDBSettings()
: m_arrItems(50)
, m_flags(0)
, m_flags(kLLDBOptionRaiseCodeLite)
, m_stackFrames(100)
{
m_types = s_DefaultTypes;
Expand Down
5 changes: 5 additions & 0 deletions LLDBDebugger/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ LLDBCallStackBase::LLDBCallStackBase(wxWindow* parent, wxWindowID id, const wxPo
GetSizer()->Fit(this);
}
Centre(wxBOTH);
// Connect events
m_dvListCtrlBacktrace->Connect(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler(LLDBCallStackBase::OnItemActivated), NULL, this);

}

LLDBCallStackBase::~LLDBCallStackBase()
{
m_dvListCtrlBacktrace->Disconnect(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler(LLDBCallStackBase::OnItemActivated), NULL, this);

}

LLDBBreakpointsPaneBase::LLDBBreakpointsPaneBase(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
Expand Down
1 change: 1 addition & 0 deletions LLDBDebugger/UI.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class LLDBCallStackBase : public wxPanel
wxDataViewListCtrl* m_dvListCtrlBacktrace;

protected:
virtual void OnItemActivated(wxDataViewEvent& event) { event.Skip(); }

public:
LLDBCallStackBase(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(500,300), long style = wxTAB_TRAVERSAL);
Expand Down
9 changes: 8 additions & 1 deletion LLDBDebugger/UI.wxcp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,14 @@
"m_label": "Style:",
"m_value": ""
}],
"m_events": [],
"m_events": [{
"m_eventName": "wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED",
"m_eventClass": "wxDataViewEvent",
"m_eventHandler": "wxDataViewEventHandler",
"m_functionNameAndSignature": "OnItemActivated(wxDataViewEvent& event)",
"m_description": "Process a wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.\nThis event is triggered by double clicking an item or pressing some special key (usually \"Enter\") when it is focused",
"m_noBody": false
}],
"m_children": [{
"m_type": 4472,
"proportion": 0,
Expand Down
10 changes: 10 additions & 0 deletions LLDBDebugger/codelite-lldb/CodeLiteLLDBApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,14 @@ void CodeLiteLLDBApp::MainLoop()
}
}

void CodeLiteLLDBApp::SelectFrame(const LLDBCommand& command)
{
wxPrintf("codelite-lldb: selecting frame %d\n", command.GetFrameId());
if ( CanInteract() ) {
m_target.GetProcess().GetSelectedThread().SetSelectedFrame( command.GetFrameId() );
m_interruptReason = kInterruptReasonNone;
NotifyStopped();
}
}

#endif
1 change: 1 addition & 0 deletions LLDBDebugger/codelite-lldb/CodeLiteLLDBApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class CodeLiteLLDBApp
void Interrupt(const LLDBCommand& command);
void LocalVariables(const LLDBCommand& command);
void ExpandVariable(const LLDBCommand& command);
void SelectFrame(const LLDBCommand& command);
};

DECLARE_APP(CodeLiteLLDBApp)
Expand Down
4 changes: 4 additions & 0 deletions LLDBDebugger/codelite-lldb/LLDBNetworkServerThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ void* LLDBNetworkServerThread::Entry()
case kCommandExpandVariable:
m_app->CallAfter( &CodeLiteLLDBApp::ExpandVariable, command);
break;

case kCommandSelectFrame:
m_app->CallAfter( &CodeLiteLLDBApp::SelectFrame, command );
break;

default:
break;
Expand Down
12 changes: 9 additions & 3 deletions LLDBDebugger/lldbdebugger-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ void LLDBDebuggerPlugin::OnLLDBStarted(LLDBEvent& event)

// instruct the debugger to 'Run'
#ifdef __WXMSW__
wxFileName fnTerminalOutout( wxFileName::GetTempDir(), "codelite-terminal.txt" );
wxFileName fnTerminalOutout( wxFileName::GetTempDir(), "codelite-terminal.txt" );
#else
wxFileName fnTerminalOutout( "/tmp/codelite-terminal.txt" );
wxFileName fnTerminalOutout( "/tmp/codelite-terminal.txt" );
#endif
CL_DEBUG("Searching for terminal info file: %s", fnTerminalOutout.GetFullPath());

Expand All @@ -366,7 +366,7 @@ void LLDBDebuggerPlugin::OnLLDBStarted(LLDBEvent& event)
DoCleanup();
return;
}

JSONRoot root( fnTerminalOutout );
wxString tty = root.toElement().namedObject("tty").toString();
m_terminalPID = root.toElement().namedObject("ProcessID").toInt(wxNOT_FOUND);
Expand All @@ -376,6 +376,11 @@ void LLDBDebuggerPlugin::OnLLDBStarted(LLDBEvent& event)
CL_DEBUG("CODELITE>> LLDB started");
wxCommandEvent e2(wxEVT_DEBUG_STARTED);
EventNotifier::Get()->AddPendingEvent( e2 );

{
wxLogNull noLog;
::wxRemoveFile( fnTerminalOutout.GetFullPath() );
}
}

void LLDBDebuggerPlugin::OnLLDBStopped(LLDBEvent& event)
Expand Down Expand Up @@ -426,6 +431,7 @@ void LLDBDebuggerPlugin::OnLLDBStopped(LLDBEvent& event)
CL_DEBUG("Deleting all pending deletion breakpoints");
m_connector.DeleteBreakpoints();
m_connector.Continue();

}
}

Expand Down
4 changes: 2 additions & 2 deletions LiteEditor.workspace
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<Project Name="wxsqlite3" ConfigName="WinDebugUnicode"/>
<Project Name="ZoomNavigator" ConfigName="WinDebugUnicode"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="CMake_Release" Selected="yes">
<WorkspaceConfiguration Name="CMake_Release" Selected="no">
<Project Name="ZoomNavigator" ConfigName="DebugUnicode"/>
<Project Name="wxsqlite3" ConfigName="WinReleaseUnicode"/>
<Project Name="wxshapeframework" ConfigName="WinReleaseUnicode"/>
Expand Down Expand Up @@ -157,7 +157,7 @@
<Project Name="CodeLiteDiff" ConfigName="DebugUnicode"/>
<Project Name="LLDBDebugger" ConfigName="DebugUnicode"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="CMake_Debug" Selected="no">
<WorkspaceConfiguration Name="CMake_Debug" Selected="yes">
<Project Name="ZoomNavigator" ConfigName="WinReleaseUnicode"/>
<Project Name="wxsqlite3" ConfigName="WinReleaseUnicode"/>
<Project Name="wxshapeframework" ConfigName="WinReleaseUnicode"/>
Expand Down

0 comments on commit 4b6349c

Please sign in to comment.