Drop gdb versionning.

Cherry picked and adapted from commit 0efc808f from the original author
of kdbg, code available at https://github.com/j6t/kdbg under GPL 2.0"

Quote from the author:
In early days of KDbg, it was important to use a suitable command to load
a core file. This was before gdb 4.16. To pick the right command, the
version number was parsed from gdb's greeting.

At least with modern gdb the regular expression does not match anymore.
So let's assume that nobody is using ancient gdb anymore, and always use
the modern command.

Signed-off-by: gregory guy <g-gregory@gmx.fr>
(cherry picked from commit 50d3d7881e)
r14.0.x
gregory guy 5 years ago committed by Michele Calgaro
parent db5c50e213
commit d4eb6e99e2
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -6,8 +6,8 @@
#include "gdbdriver.h"
#include "exprwnd.h"
#include <ntqregexp.h>
#include <ntqstringlist.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);

@ -75,7 +75,6 @@ public:
virtual TQString parseSetVariable(const char* output);
virtual TQString editableValue(VarTree* value);
protected:
int m_gdbMajor, m_gdbMinor;
TQString m_programWD; /* just an intermediate storage */
TQString m_redirect; /* redirection to /dev/null */
bool m_haveCoreFile;

@ -6,7 +6,7 @@
#include "xsldbgdriver.h"
#include "exprwnd.h"
#include <ntqstringlist.h>
#include <tqstringlist.h>
#include <tdelocale.h> /* i18n */
#include <ctype.h>
#include <stdlib.h> /* strtol, atoi */
@ -104,7 +104,7 @@ static XsldbgCmdInfo cmds[] = {
#define MAX_FMTLEN 200
XsldbgDriver::XsldbgDriver():
DebuggerDriver(), m_gdbMajor(2), m_gdbMinor(0)
DebuggerDriver()
{
m_promptRE.setPattern("\\(xsldbg\\) .*> ");
m_promptMinLen = 11;
@ -258,39 +258,6 @@ XsldbgDriver::commandFinished(CmdQueueItem * cmd)
return;
}
switch (cmd->m_cmd) {
case DCinitialize:
// get version number from preamble
{
int len;
TQRegExp xsldbgVersion("^XSLDBG [0-9]+\\.[0-9]+\\.[0-9]+");
int offset = xsldbgVersion.match(m_output, 0, &len);
if (offset >= 0) {
char *start = m_output + offset + 7; // skip "^XSLDBG "
char *end;
TRACE("Reading version");
TRACE(start);
m_gdbMajor = strtol(start, &end, 10);
m_gdbMinor = strtol(end + 1, 0, 10); // skip "."
if (start == end) {
// nothing was parsed
m_gdbMajor = 0;
m_gdbMinor = 7;
}
} else {
// assume some default version (what would make sense?)
m_gdbMajor = 0;
m_gdbMinor = 7;
}
TRACE(TQString("Got version ") +
TQString::number(m_gdbMajor) + "." +
TQString::number(m_gdbMinor));
break;
}
default:;
}
/* ok, the command is ready */
emit commandReceived(cmd, m_output);

@ -8,7 +8,7 @@
#define XSLDBGDRIVER_H
#include "dbgdriver.h"
#include "ntqregexp.h"
#include "tqregexp.h"
class XsldbgDriver:public DebuggerDriver {
@ -86,7 +86,6 @@ class XsldbgDriver:public DebuggerDriver {
virtual TQString parseSetVariable(const char* output);
protected:
int m_gdbMajor, m_gdbMinor;
TQString m_programWD; /* just an intermediate storage */
TQString m_xslFile; /* needed to display it initially */
bool m_haveDataFile; /* have we set the XML data file to use? */

Loading…
Cancel
Save