Skip to content

First approach to show source files #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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 kdbg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ set(kdbg_SRCS
prefmisc.cpp
pgmsettings.cpp
watchwindow.cpp
srcfileswindow.cpp
dbgmainwnd.cpp
main.cpp
)
Expand Down
6 changes: 6 additions & 0 deletions kdbg/dbgdriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enum DbgCommand {
DCexamine,
DCinfoline,
DCinfotarget,
DCinfosources,
DCdisassemble,
DCsetdisassflavor,
DCsetargs,
Expand Down Expand Up @@ -545,6 +546,11 @@ class DebuggerDriver : public QProcess
*/
virtual QString parseInfoTarget(const char* output) = 0;

/**
* Parse the output of the DCinfosources command.
*/
virtual QString parseInfoSources(const char* output) = 0;

/**
* Parses the ouput of the DCdisassemble command.
*/
Expand Down
15 changes: 14 additions & 1 deletion kdbg/dbgmainwnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "memwindow.h"
#include "ttywnd.h"
#include "watchwindow.h"
#include "srcfileswindow.h"
#include "procattach.h"
#include "prefdebugger.h"
#include "prefmisc.h"
Expand Down Expand Up @@ -100,6 +101,9 @@ DebuggerMainWnd::DebuggerMainWnd() :
QDockWidget* dw8 = createDockWidget("Memory", i18n("Memory"));
m_memoryWindow = new MemoryWindow(dw8);
dw8->setWidget(m_memoryWindow);
QDockWidget* dw9 = createDockWidget("SrcFiles", i18n("Source Files"));
m_srcFiles = new SrcFilesWindow(dw9);
dw9->setWidget(m_srcFiles);

m_debugger = new KDebugger(this, m_localVariables, m_watches->watchVariables(), m_btWindow);

Expand Down Expand Up @@ -178,6 +182,12 @@ DebuggerMainWnd::DebuggerMainWnd() :
connect(m_localVariables, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(slotLocalsPopup(const QPoint&)));

// connect src files to src files window
connect(m_debugger, SIGNAL(sourceFiles(QString&)),
m_srcFiles, SLOT(sourceFiles(QString&)));
connect(m_srcFiles, SIGNAL(activateFileLine(const QString&,int,const DbgAddr&)),
m_filesWindow, SLOT(activate(const QString&,int,const DbgAddr&)));

makeDefaultLayout();
setupGUI(KXmlGuiWindow::Default, "kdbgui.rc");
restoreSettings(KSharedConfig::openConfig());
Expand Down Expand Up @@ -206,6 +216,7 @@ DebuggerMainWnd::~DebuggerMainWnd()
delete m_localVariables;
delete m_btWindow;
delete m_filesWindow;
delete m_srcFiles;

delete m_outputTermProc;
}
Expand Down Expand Up @@ -286,7 +297,8 @@ void DebuggerMainWnd::initKAction()
{ m_bpTable, "view_breakpoints", &m_bpTableAction },
{ m_threads, "view_threads", &m_threadsAction },
{ m_ttyWindow, "view_output", &m_ttyWindowAction },
{ m_memoryWindow, "view_memory", &m_memoryWindowAction }
{ m_memoryWindow, "view_memory", &m_memoryWindowAction },
{ m_srcFiles, "view_srcfiles", &m_srcFilesAction},
};
for (unsigned i = 0; i < sizeof(dw)/sizeof(dw[0]); i++) {
QDockWidget* d = dockParent(dw[i].w);
Expand Down Expand Up @@ -628,6 +640,7 @@ void DebuggerMainWnd::makeDefaultLayout()
tabifyDockWidget(dockParent(m_bpTable), dockParent(m_ttyWindow));
tabifyDockWidget(dockParent(m_ttyWindow), dockParent(m_btWindow));
tabifyDockWidget(dockParent(m_threads), dockParent(m_watches));
tabifyDockWidget(dockParent(m_watches), dockParent(m_srcFiles));
dockParent(m_localVariables)->setVisible(true);
dockParent(m_ttyWindow)->setVisible(true);
dockParent(m_watches)->setVisible(true);
Expand Down
3 changes: 3 additions & 0 deletions kdbg/dbgmainwnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ThreadList;
class MemoryWindow;
class TTYWindow;
class WatchWindow;
class SrcFilesWindow;
class KDebugger;
class DebuggerDriver;
struct DbgAddr;
Expand Down Expand Up @@ -76,6 +77,7 @@ class DebuggerMainWnd : public KXmlGuiWindow
TTYWindow* m_ttyWindow;
ThreadList* m_threads;
MemoryWindow* m_memoryWindow;
SrcFilesWindow* m_srcFiles;

QTimer m_backTimer;

Expand All @@ -95,6 +97,7 @@ class DebuggerMainWnd : public KXmlGuiWindow
QAction* m_ttyWindowAction;
QAction* m_threadsAction;
QAction* m_memoryWindowAction;
QAction* m_srcFilesAction;
QAction* m_runAction;
QAction* m_stepIntoAction;
QAction* m_stepOverAction;
Expand Down
10 changes: 10 additions & 0 deletions kdbg/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ bool KDebugger::debugProgram(const QString& name,
m_executable = name;

m_d->executeCmd(DCinfotarget);
m_d->executeCmd(DCinfosources);

// set remote target
if (!m_remoteDevice.isEmpty()) {
Expand Down Expand Up @@ -1124,6 +1125,9 @@ void KDebugger::parse(CmdQueueItem* cmd, const char* output)
case DCinfotarget:
handleInfoTarget(output);
break;
case DCinfosources:
handleInfoSources(output);
break;
case DCdisassemble:
handleDisassemble(cmd, output);
break;
Expand Down Expand Up @@ -2190,6 +2194,12 @@ void KDebugger::handleInfoTarget(const char* output)
m_cpuTarget = m_d->parseInfoTarget(output);
}

void KDebugger::handleInfoSources(const char* output)
{
QString s = m_d->parseInfoSources(output);
emit sourceFiles(s);
}

void KDebugger::handleDisassemble(CmdQueueItem* cmd, const char* output)
{
emit disassembled(cmd->m_fileName, cmd->m_lineNo,
Expand Down
6 changes: 6 additions & 0 deletions kdbg/debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ protected slots:
void handleMemoryDump(const char* output);
void handleInfoLine(CmdQueueItem* cmd, const char* output);
void handleInfoTarget(const char* output);
void handleInfoSources(const char* output);
void handleDisassemble(CmdQueueItem* cmd, const char* output);
void handleThreadList(const char* output);
void handleSetPC(const char* output);
Expand Down Expand Up @@ -590,6 +591,11 @@ public slots:
*/
void restoreProgramSpecific(KConfigBase* config);

/**
* Gives source files to tree view
*/
void sourceFiles(QString &);

protected:
ExprWnd& m_localVariables;
ExprWnd& m_watchVariables;
Expand Down
16 changes: 16 additions & 0 deletions kdbg/gdbdriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static GdbCmdInfo cmds[] = {
{ DCexamine, "x %s %s\n", GdbCmdInfo::argString2 },
{ DCinfoline, "info line %s:%d\n", GdbCmdInfo::argStringNum },
{ DCinfotarget, "info target\n", GdbCmdInfo::argNone},
{ DCinfosources, "info sources\n", GdbCmdInfo::argNone},
{ DCdisassemble, "disassemble %s %s\n", GdbCmdInfo::argString2 },
{ DCsetdisassflavor, "set disassembly-flavor %s\n", GdbCmdInfo::argString},
{ DCsetargs, "set args %s\n", GdbCmdInfo::argString },
Expand Down Expand Up @@ -2593,6 +2594,21 @@ QString GdbDriver::parseInfoTarget(const char* output)
return {};
}

QString GdbDriver::parseInfoSources(const char* output)
{
auto p1 = strstr(output, "read in:\n");
if (p1) {
p1 += 9;
auto p2 = strstr(p1, "\nSource files");
if (p2) {
auto p3 = strstr(p1, "on demand:\n");
p3 += 11;
return QString::fromUtf8(p1, p2 - p1) + QString(p3);
}
}
return {};
}

std::list<DisassembledCode> GdbDriver::parseDisassemble(const char* output)
{
std::list<DisassembledCode> code;
Expand Down
1 change: 1 addition & 0 deletions kdbg/gdbdriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class GdbDriver : public DebuggerDriver
bool parseInfoLine(const char* output,
QString& addrFrom, QString& addrTo) override;
QString parseInfoTarget(const char* output) override;
QString parseInfoSources(const char* output) override;
std::list<DisassembledCode> parseDisassemble(const char* output) override;
QString parseMemoryDump(const char* output, std::list<MemoryDump>& memdump) override;
QString parseSetVariable(const char* output) override;
Expand Down
1 change: 1 addition & 0 deletions kdbg/kdbgui.rc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<Action name="view_threads"/>
<Action name="view_output"/>
<Action name="view_memory"/>
<Action name="view_srcfiles"/>
</Menu>
<Menu name="execution"><text>E&amp;xecution</text>
<Action name="exec_run"/>
Expand Down
Loading