KDevelop API Documentation

languages/cpp/debugger/disassemblewidget.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 begin : Tues Jan 3 2000 00003 copyright : (C) 2000 by John Birch 00004 email : jbb@kdevelop.org 00005 ***************************************************************************/ 00006 00007 /*************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 00016 #include "disassemblewidget.h" 00017 00018 #include <kdebug.h> 00019 #include <kdeversion.h> 00020 #if KDE_VERSION > 305 00021 # include <ktextedit.h> 00022 #endif 00023 #include <kglobalsettings.h> 00024 00025 #include <qdict.h> 00026 #include <qheader.h> 00027 #include <qtextedit.h> 00028 00029 #include <stdlib.h> 00030 00031 namespace GDBDebugger 00032 { 00033 00034 /***************************************************************************/ 00035 /***************************************************************************/ 00036 /***************************************************************************/ 00037 00038 DisassembleWidget::DisassembleWidget(QWidget *parent, const char *name) 00039 : QTextEdit(parent, name), 00040 active_(false), 00041 lower_(0), 00042 upper_(0), 00043 address_(0) 00044 { 00045 setFont(KGlobalSettings::fixedFont()); 00046 setReadOnly(true); 00047 } 00048 00049 /***************************************************************************/ 00050 00051 DisassembleWidget::~DisassembleWidget() 00052 {} 00053 00054 /***************************************************************************/ 00055 00056 bool DisassembleWidget::displayCurrent() 00057 { 00058 Q_ASSERT(address_ >= lower_ || address_ <= upper_); 00059 00060 int line; 00061 for (line=0; line < paragraphs(); line++) 00062 { 00063 int address = strtol(text(line).latin1(), 0, 0); 00064 if (address == address_) 00065 { 00066 // put cursor at start of line and highlight the line 00067 setCursorPosition(line, 0); 00068 setSelection(line,0,line+1,0,0); 00069 return true; 00070 } 00071 } 00072 00073 return false; 00074 } 00075 00076 /***************************************************************************/ 00077 00078 void DisassembleWidget::slotBPState(const Breakpoint&) 00079 { 00080 if (!active_) 00081 return; 00082 } 00083 00084 /***************************************************************************/ 00085 00086 void DisassembleWidget::slotDisassemble(char *buf) 00087 { 00088 if (!active_) 00089 return; 00090 00091 clear(); 00092 // Skip the first line (just header info) 00093 char *start = strchr(buf, '\n'); 00094 00095 // Make sure there is something there 00096 if (start) 00097 { 00098 append(start+1); 00099 // Skip the last two lines (just trailer info) 00100 removeParagraph(paragraphs()-1); 00101 removeParagraph(paragraphs()-1); 00102 00103 if (paragraphs()) 00104 { 00105 lower_ = strtol(text(0).latin1(), 0, 0); 00106 upper_ = strtol(text(paragraphs()-1).latin1(), 0, 0); 00107 displayCurrent(); 00108 } 00109 else 00110 { 00111 lower_ = 0; 00112 upper_ = 0; 00113 } 00114 } 00115 } 00116 00117 /***************************************************************************/ 00118 00119 void DisassembleWidget::slotActivate(bool activate) 00120 { 00121 kdDebug(9012) << "Disassemble widget active: " << activate << endl; 00122 00123 if (active_ != activate) 00124 { 00125 active_ = activate; 00126 if (active_ && address_) 00127 { 00128 if (address_ < lower_ || address_ > upper_ || !displayCurrent()) 00129 getNextDisplay(); 00130 } 00131 } 00132 } 00133 00134 /***************************************************************************/ 00135 00136 void DisassembleWidget::slotShowStepInSource( const QString &, int, 00137 const QString &currentAddress) 00138 { 00139 kdDebug(9012) << "DisasssembleWidget::slotShowStepInSource()" << endl; 00140 00141 currentAddress_ = currentAddress; 00142 address_ = strtol(currentAddress.latin1(), 0, 0); 00143 if (!active_) 00144 return; 00145 00146 if (address_ < lower_ || address_ > upper_ || !displayCurrent()) 00147 getNextDisplay(); 00148 } 00149 00150 /***************************************************************************/ 00151 00152 void DisassembleWidget::getNextDisplay() 00153 { 00154 kdDebug(9012) << "DisasssembleWidget::getNextDisplay()" << endl; 00155 00156 if (address_) 00157 { 00158 Q_ASSERT(!currentAddress_.isNull()); 00159 00160 // restrict this to a managable size - some functions are _big_ 00161 QString endAddress; 00162 endAddress.sprintf("0x%x", (uint)address_+128); 00163 emit disassemble(currentAddress_, endAddress); 00164 } 00165 else 00166 emit disassemble("", ""); 00167 } 00168 00169 00170 void DisassembleWidget::showEvent(QShowEvent*) 00171 { 00172 slotActivate(true); 00173 } 00174 00175 00176 void DisassembleWidget::hideEvent(QHideEvent*) 00177 { 00178 slotActivate(false); 00179 } 00180 00181 /***************************************************************************/ 00182 00183 } 00184 00185 #include "disassemblewidget.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:01 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003