1
/***************************************************************************
2
begin : Tues Jan 3 2000
3
copyright : (C) 2000 by John Birch
4
email : jbb@kdevelop.org
5
***************************************************************************/
7
/***************************************************************************
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
14
***************************************************************************/
16
#include "disassemblewidget.h"
17
#include "gdbcontroller.h"
18
#include "gdbcommand.h"
21
#include <kdeversion.h>
22
#include <ktextedit.h>
23
#include <kglobalsettings.h>
27
#include <qtextedit.h>
34
/***************************************************************************/
35
/***************************************************************************/
36
/***************************************************************************/
38
DisassembleWidget::DisassembleWidget(GDBController* controller, QWidget *parent, const char *name)
39
: QTextEdit(parent, name), controller_(controller),
45
setFont(KGlobalSettings::fixedFont());
49
/***************************************************************************/
51
DisassembleWidget::~DisassembleWidget()
54
/***************************************************************************/
56
bool DisassembleWidget::displayCurrent()
58
Q_ASSERT(address_ >= lower_ || address_ <= upper_);
61
for (line=0; line < paragraphs(); line++)
63
unsigned long address = strtoul(text(line).latin1(), 0, 0);
64
if (address == address_)
66
// put cursor at start of line and highlight the line
67
setCursorPosition(line, 0);
68
setSelection(line,0,line+1,0,0);
76
/***************************************************************************/
78
void DisassembleWidget::slotActivate(bool activate)
80
kdDebug(9012) << "Disassemble widget active: " << activate << endl;
82
if (active_ != activate)
85
if (active_ && address_)
87
if (address_ < lower_ || address_ > upper_ || !displayCurrent())
93
/***************************************************************************/
95
void DisassembleWidget::slotShowStepInSource( const QString &, int,
96
const QString ¤tAddress)
98
kdDebug(9012) << "DisasssembleWidget::slotShowStepInSource()" << endl;
100
currentAddress_ = currentAddress;
101
address_ = strtoul(currentAddress.latin1(), 0, 0);
105
if (address_ < lower_ || address_ > upper_ || !displayCurrent())
109
/***************************************************************************/
111
void DisassembleWidget::getNextDisplay()
113
kdDebug(9012) << "DisasssembleWidget::getNextDisplay()" << endl;
117
Q_ASSERT(!currentAddress_.isNull());
119
QString cmd = QString("-data-disassemble -s $pc -e \"$pc + 128\" -- 0");
120
controller_->addCommandToFront(
121
new GDBCommand( cmd, this, &DisassembleWidget::memoryRead ) );
125
/***************************************************************************/
127
void DisassembleWidget::memoryRead(const GDBMI::ResultRecord& r)
129
const GDBMI::Value& content = r["asm_insns"];
134
for(unsigned i = 0; i < content.size(); ++i)
136
const GDBMI::Value& line = content[i];
138
QString addr = line["address"].literal();
139
QString fct = line["func-name"].literal();
140
QString offs = line["offset"].literal();
141
QString inst = line["inst"].literal();
143
rawdata += QString(addr + " " + fct+"+"+offs + " " + inst + "\n");
146
lower_ = strtoul(addr.latin1(), 0, 0);
147
} else if (i == content.size()-1) {
148
upper_ = strtoul(addr.latin1(), 0, 0);
158
void DisassembleWidget::showEvent(QShowEvent*)
164
void DisassembleWidget::hideEvent(QHideEvent*)
169
/***************************************************************************/
173
#include "disassemblewidget.moc"