Skip to content

Commit

Permalink
- added an option to set the watches view format to one of: Hex, natu…
Browse files Browse the repository at this point in the history
…ral, bin, octal & decimal

FR#[2004746]


git-svn-id: https://codelite.svn.sourceforge.net/svnroot/codelite/trunk@1764 9da81c78-c036-0410-9e1f-a2b0375e4b5a
  • Loading branch information
eranif committed Jun 28, 2008
1 parent 9089ae6 commit c8c80fa
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 106 deletions.
13 changes: 11 additions & 2 deletions Debugger/debuggergdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ void DbgGdb::DoProcessAsyncCommand(wxString &line, wxString &id)
}
}

bool DbgGdb::EvaluateExpressionToString(const wxString &expression)
bool DbgGdb::EvaluateExpressionToString(const wxString &expression, const wxString &format)
{
static int counter(0);
wxString watchName(wxT("watch_num_"));
Expand All @@ -760,8 +760,17 @@ bool DbgGdb::EvaluateExpressionToString(const wxString &expression)
return false;
}

command.Clear();
command.clear();
command << wxT("-var-set-format ") << watchName << wxT(" ") << format;
//first create the expression
res = WriteCommand(command, NULL);
if (!res) {
//probably gdb is down
return false;
}

//execute the watch command
command.clear();
command << wxT("-var-evaluate-expression ") << watchName;
res = WriteCommand(command, new DbgCmdHandlerEvalExpr(m_observer, expression));
if (!res) {
Expand Down
2 changes: 1 addition & 1 deletion Debugger/debuggergdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class DbgGdb : public InteractiveProcess, public IDebugger
virtual bool IsRunning();
virtual bool ExecuteCmd(const wxString &cmd);
virtual bool EvaluateExpressionToTree(const wxString &expression);
virtual bool EvaluateExpressionToString(const wxString &expression);
virtual bool EvaluateExpressionToString(const wxString &expression, const wxString &format);
virtual bool QueryLocals();
virtual bool ListFrames();
virtual bool ListThreads(ThreadEntryArray &threads);
Expand Down
90 changes: 48 additions & 42 deletions Interfaces/debugger.h
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : debugger.h
//
// copyright : (C) 2008 by Eran Ifrah
// file name : debugger.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef DEBUGGER_H
#ifndef DEBUGGER_H
#define DEBUGGER_H

#include "wx/string.h"
#include "wx/arrstr.h"
#include "wx/event.h"
#include "vector"

enum DebuggerCommands
{
enum DebuggerCommands {
DBG_PAUSE = 0,
DBG_NEXT,
DBG_STEPIN,
Expand Down Expand Up @@ -66,13 +65,13 @@ struct ThreadEntry {
typedef std::vector<StackEntry> StackEntryArray;
typedef std::vector<ThreadEntry> ThreadEntryArray;

struct BreakpointInfo
{
struct BreakpointInfo {
wxString file;
int lineno;
};

class DebuggerInformation {
class DebuggerInformation
{
public:
wxString name;
wxString path;
Expand All @@ -81,20 +80,19 @@ class DebuggerInformation {
bool breakAtWinMain;

public:
DebuggerInformation()
: name(wxEmptyString)
, path(wxEmptyString)
, enableDebugLog(false)
, enablePendingBreakpoints(true)
DebuggerInformation()
: name(wxEmptyString)
, path(wxEmptyString)
, enableDebugLog(false)
, enablePendingBreakpoints(true)
#ifdef __WXMAC__
, breakAtWinMain(true)
, breakAtWinMain(true)
#else
, breakAtWinMain(false)
, breakAtWinMain(false)
#endif
{}

~DebuggerInformation()
{}
~DebuggerInformation() {}
};


Expand All @@ -116,20 +114,26 @@ class EnvironmentConfig;
* \author Eran
*
*/
class IDebugger
class IDebugger
{
protected:
IDebuggerObserver *m_observer;
DebuggerInformation m_info;
EnvironmentConfig *m_env;

public:
IDebugger() : m_env(NULL) {};
virtual ~IDebugger(){};
virtual void SetObserver(IDebuggerObserver *observer) { m_observer = observer; }
virtual IDebuggerObserver *GetObserver(){return m_observer;}
virtual void SetEnvironment(EnvironmentConfig *env){m_env = env;}

virtual ~IDebugger() {};
virtual void SetObserver(IDebuggerObserver *observer) {
m_observer = observer;
}
virtual IDebuggerObserver *GetObserver() {
return m_observer;
}
virtual void SetEnvironment(EnvironmentConfig *env) {
m_env = env;
}

// Debugger operations
virtual bool Start(const wxString &debuggerPath, const wxString &exeName, const wxString &cwd, const std::vector<BreakpointInfo> &bpList) = 0;
virtual bool Start(const wxString &exeName, const wxString &cwd, const std::vector<BreakpointInfo> &bpList) = 0;
Expand All @@ -152,14 +156,16 @@ class IDebugger
virtual bool QueryLocals() = 0;
virtual bool ListFrames() = 0;
virtual bool SetFrame(int frame) = 0;
virtual void SetDebuggerInformation(const DebuggerInformation& info){m_info = info;}
virtual void SetDebuggerInformation(const DebuggerInformation& info) {
m_info = info;
}
virtual bool ListThreads(ThreadEntryArray &threads) = 0;
virtual bool SelectThread(long threadId) = 0;
virtual void Poke() = 0;
//We provide two ways of evulating an expressions:
//The short one, which returns a string, and long one
//which returns a tree of the result
virtual bool EvaluateExpressionToString(const wxString &expression) = 0;
virtual bool EvaluateExpressionToString(const wxString &expression, const wxString &format) = 0;
virtual bool EvaluateExpressionToTree(const wxString &expression) = 0;
};

Expand Down
7 changes: 4 additions & 3 deletions LiteEditor/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ Manager::Manager(void)
, m_quickWatchDlg(NULL)
, m_frameLineno(wxNOT_FOUND)
, m_useTipWin(false)
//, m_debuggerTipWin(NULL)
, m_tipWinPos(wxNOT_FOUND)
{
}
Expand Down Expand Up @@ -2170,9 +2169,11 @@ void Manager::UpdateDebuggerPane()
} else if (pane->GetNotebook()->GetCurrentPage() == pane->GetWatchesTable()) {
//update the watches table
wxArrayString expressions = pane->GetWatchesTable()->GetExpressions();
wxString format = pane->GetWatchesTable()->GetDisplayFormat();
for (size_t i=0; i<expressions.GetCount(); i++) {
dbgr->EvaluateExpressionToString(expressions.Item(i));
dbgr->EvaluateExpressionToString(expressions.Item(i), format);
}

} else if (pane->GetNotebook()->GetCurrentPage() == (wxWindow*)pane->GetFrameListView()) {
//update the stack call
dbgr->ListFrames();
Expand Down Expand Up @@ -2734,7 +2735,7 @@ wxString Manager::GetProjectExecutionCommand(const wxString& projectName, wxStri
//expand variables
wxString cmd = bldConf->GetCommand();
cmd = ExpandVariables(cmd, GetProject(projectName));

wxString cmdArgs = bldConf->GetCommandArguments();
cmdArgs = ExpandVariables(cmdArgs, GetProject(projectName));

Expand Down
2 changes: 1 addition & 1 deletion LiteEditor/manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Manager : public wxEvtHandler, public IDebuggerObserver
bool m_useTipWin;
long m_tipWinPos;
wxString m_installDir;

public:
/*!
* \brief
Expand Down
13 changes: 13 additions & 0 deletions LiteEditor/simpletable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,16 @@ void SimpleTable::OnMenuCopyValue(wxCommandEvent& event)
}
}

void SimpleTable::OnDisplayFormat(wxCommandEvent& event)
{
wxUnusedVar(event);

// refresh the table
RefreshValues();
}

wxString SimpleTable::GetDisplayFormat()
{
return m_choiceDisplayFormat->GetStringSelection();
}

4 changes: 3 additions & 1 deletion LiteEditor/simpletable.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class SimpleTable : public SimpleTableBase
void OnMenuCopyBoth(wxCommandEvent &event);
void OnMenuDerefExpr(wxCommandEvent &event);
void OnListEditLabelEnd(wxListEvent &event);

void OnDisplayFormat(wxCommandEvent &event);

public:
/** Constructor */
SimpleTable( wxWindow* parent );
Expand All @@ -76,6 +77,7 @@ class SimpleTable : public SimpleTableBase
wxArrayString GetExpressions();
void Clear();
void RefreshValues();
wxString GetDisplayFormat();
};

#endif // __simpletable__
63 changes: 37 additions & 26 deletions LiteEditor/simpletablebase.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : simpletablebase.cpp
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 26 2007)
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 16 2008)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
Expand All @@ -49,6 +25,21 @@ SimpleTableBase::SimpleTableBase( wxWindow* parent, wxWindowID id, const wxPoint
m_listTable = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_EDIT_LABELS|wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES );
bSizer1->Add( m_listTable, 1, wxEXPAND|wxALL, 1 );

wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxHORIZONTAL );

m_staticTextDisplayText = new wxStaticText( this, wxID_ANY, wxT("Display Format:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextDisplayText->Wrap( -1 );
bSizer2->Add( m_staticTextDisplayText, 0, wxALL, 5 );

wxString m_choiceDisplayFormatChoices[] = { wxT("natural"), wxT("hexadecimal"), wxT("binary"), wxT("octal"), wxT("decimal") };
int m_choiceDisplayFormatNChoices = sizeof( m_choiceDisplayFormatChoices ) / sizeof( wxString );
m_choiceDisplayFormat = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceDisplayFormatNChoices, m_choiceDisplayFormatChoices, 0 );
m_choiceDisplayFormat->SetSelection( 0 );
bSizer2->Add( m_choiceDisplayFormat, 0, 0, 5 );

bSizer1->Add( bSizer2, 0, 0, 5 );

this->SetSizer( bSizer1 );
this->Layout();

Expand All @@ -66,4 +57,24 @@ SimpleTableBase::SimpleTableBase( wxWindow* parent, wxWindowID id, const wxPoint
m_listTable->Connect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( SimpleTableBase::OnItemRightClick ), NULL, this );
m_listTable->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( SimpleTableBase::OnItemSelected ), NULL, this );
m_listTable->Connect( wxEVT_COMMAND_LIST_KEY_DOWN, wxListEventHandler( SimpleTableBase::OnListKeyDown ), NULL, this );
m_choiceDisplayFormat->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( SimpleTableBase::OnDisplayFormat ), NULL, this );
}

SimpleTableBase::~SimpleTableBase()
{
// Disconnect Events
this->Disconnect( ID_TOOLNEW, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SimpleTableBase::OnNewWatch ) );
this->Disconnect( ID_TOOLNEW, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SimpleTableBase::OnNewWatchUI ) );
this->Disconnect( ID_TOOLDELETE, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SimpleTableBase::OnDeleteWatch ) );
this->Disconnect( ID_TOOLDELETE, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SimpleTableBase::OnDeleteWatchUI ) );
this->Disconnect( ID_TOOLDELETEALL, wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SimpleTableBase::OnDeleteAll ) );
this->Disconnect( ID_TOOLDELETEALL, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SimpleTableBase::OnDeleteAllUI ) );
m_listTable->Disconnect( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, wxListEventHandler( SimpleTableBase::OnListEditLabelBegin ), NULL, this );
m_listTable->Disconnect( wxEVT_COMMAND_LIST_END_LABEL_EDIT, wxListEventHandler( SimpleTableBase::OnListEditLabelEnd ), NULL, this );
m_listTable->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( SimpleTableBase::OnItemActivated ), NULL, this );
m_listTable->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( SimpleTableBase::OnItemDeSelected ), NULL, this );
m_listTable->Disconnect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( SimpleTableBase::OnItemRightClick ), NULL, this );
m_listTable->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( SimpleTableBase::OnItemSelected ), NULL, this );
m_listTable->Disconnect( wxEVT_COMMAND_LIST_KEY_DOWN, wxListEventHandler( SimpleTableBase::OnListKeyDown ), NULL, this );
m_choiceDisplayFormat->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( SimpleTableBase::OnDisplayFormat ), NULL, this );
}
Loading

0 comments on commit c8c80fa

Please sign in to comment.