@ -6,8 +6,8 @@
# include "gdbdriver.h"
# include "exprwnd.h"
# include < n tqregexp.h>
# include < n tqstringlist.h>
# include < tqregexp.h>
# include < tqstringlist.h>
# include <tdelocale.h> /* i18n */
# include <ctype.h>
# include <stdlib.h> /* strtol, atoi */
@ -71,7 +71,11 @@ static GdbCmdInfo cmds[] = {
{ DCtty , " tty %s \n " , GdbCmdInfo : : argString } ,
{ DCexecutable , " file \" %s \" \n " , GdbCmdInfo : : argString } ,
{ DCtargetremote , " target remote %s \n " , GdbCmdInfo : : argString } ,
{ DCcorefile , " core-file %s \n " , GdbCmdInfo : : argString } ,
# ifdef __FreeBSD__
{ DCcorefile , " target FreeBSD-core %s \n " , GdbCmdInfo : : argString } ,
# else
{ DCcorefile , " target core %s \n " , GdbCmdInfo : : argString } ,
# endif
{ DCattach , " attach %s \n " , GdbCmdInfo : : argString } ,
{ DCinfolinemain , " kdbg_infolinemain \n " , GdbCmdInfo : : argNone } ,
{ DCinfolocals , " kdbg__alllocals \n " , GdbCmdInfo : : argNone } ,
@ -124,8 +128,7 @@ static GdbCmdInfo cmds[] = {
# define MAX_FMTLEN 200
GdbDriver : : GdbDriver ( ) :
DebuggerDriver ( ) ,
m_gdbMajor ( 4 ) , m_gdbMinor ( 16 )
DebuggerDriver ( )
{
strcpy ( m_prompt , PROMPT ) ;
m_promptMinLen = PROMPT_LEN ;
@ -279,69 +282,6 @@ void GdbDriver::commandFinished(CmdQueueItem* cmd)
return ;
}
switch ( cmd - > m_cmd ) {
case DCinitialize :
// get version number from preamble
{
int len ;
TQRegExp GDBVersion ( " \\ nGDB [0-9]+ \\ .[0-9]+ " ) ;
int offset = GDBVersion . match ( m_output , 0 , & len ) ;
if ( offset > = 0 ) {
char * start = m_output + offset + 5 ; // skip "\nGDB "
char * end ;
m_gdbMajor = strtol ( start , & end , 10 ) ;
m_gdbMinor = strtol ( end + 1 , 0 , 10 ) ; // skip "."
if ( start = = end ) {
// nothing was parsed
m_gdbMajor = 4 ;
m_gdbMinor = 16 ;
}
} else {
// assume some default version (what would make sense?)
m_gdbMajor = 4 ;
m_gdbMinor = 16 ;
}
// use a feasible core-file command
if ( m_gdbMajor > 4 | | ( m_gdbMajor = = 4 & & m_gdbMinor > = 16 ) ) {
# ifdef __FreeBSD__
cmds [ DCcorefile ] . fmt = " target FreeBSD-core %s \n " ;
# else
cmds [ DCcorefile ] . fmt = " target core %s \n " ;
# endif
} else {
cmds [ DCcorefile ] . fmt = " core-file %s \n " ;
}
}
{
/*
* Check for GDB 7.1 or later ; the syntax for the disassemble
* command has changed .
* This RE picks the last version number in the first line ,
* because at least OpenSUSE writes its own version number
* in the first line ( but before GDB ' s version number ) .
*/
TQRegExp re (
" " // must be preceded by space
" [(]? " // SLES 10 embeds in parentheses
" ( \\ d+) \\ .( \\ d+) " // major, minor
" [^ ]* \\ n " // no space until end of line
) ;
int pos = re . search ( m_output ) ;
const char * disass = " disassemble %s %s \n " ;
if ( pos > = 0 ) {
int major = re . cap ( 1 ) . toInt ( ) ;
int minor = re . cap ( 2 ) . toInt ( ) ;
if ( major > 7 | | ( major = = 7 & & minor > = 1 ) )
{
disass = " disassemble %s, %s \n " ;
}
}
cmds [ DCdisassemble ] . fmt = disass ;
}
break ;
default : ;
}
/* ok, the command is ready */
emit commandReceived ( cmd , m_output ) ;