diff options
author | gregory guy <[email protected]> | 2019-05-30 13:11:39 +0200 |
---|---|---|
committer | gregory guy <[email protected]> | 2019-05-30 13:39:48 +0200 |
commit | 50d3d7881eee76283e171d9dc280538cccc46baf (patch) | |
tree | 698075e9d724c55c214858c582cab1d54e5f7785 | |
parent | 32c09ab3ef72e5609a01990786a1e7d984b4b144 (diff) | |
download | kdbg-50d3d7881eee76283e171d9dc280538cccc46baf.tar.gz kdbg-50d3d7881eee76283e171d9dc280538cccc46baf.zip |
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 <[email protected]>
-rw-r--r-- | kdbg/gdbdriver.cpp | 76 | ||||
-rw-r--r-- | kdbg/gdbdriver.h | 1 | ||||
-rw-r--r-- | kdbg/xsldbgdriver.cpp | 37 | ||||
-rw-r--r-- | kdbg/xsldbgdriver.h | 3 |
4 files changed, 11 insertions, 106 deletions
diff --git a/kdbg/gdbdriver.cpp b/kdbg/gdbdriver.cpp index 5a5ec05..f76f753 100644 --- a/kdbg/gdbdriver.cpp +++ b/kdbg/gdbdriver.cpp @@ -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); diff --git a/kdbg/gdbdriver.h b/kdbg/gdbdriver.h index 2cbbb85..4cdfc4b 100644 --- a/kdbg/gdbdriver.h +++ b/kdbg/gdbdriver.h @@ -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; diff --git a/kdbg/xsldbgdriver.cpp b/kdbg/xsldbgdriver.cpp index d59023f..63b3227 100644 --- a/kdbg/xsldbgdriver.cpp +++ b/kdbg/xsldbgdriver.cpp @@ -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); diff --git a/kdbg/xsldbgdriver.h b/kdbg/xsldbgdriver.h index b4e2f43..bc24af4 100644 --- a/kdbg/xsldbgdriver.h +++ b/kdbg/xsldbgdriver.h @@ -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? */ |