KDevelop API Documentation

languages/java/debugger/disassemblewidget.cpp

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