Branch: master

a57f5f7c 2019-05-31 11:51:31 Johannes Sixt
Fix assembler code display with gdb 7.1 and later.

The syntax of the 'disassemble' command changed in gdb 7.1: it now requires
a comma between the two address expressions. Previously, KDbg showed an
error message instead of assembler code when a plus in front of a source
code line was clicked.

Reported by Gerfried Essler.

This reverts part of the previous commit.
(cherry picked from upstream commit b6ee6a035abe41f7c0d59fbd830e895b6edeb748)
M kdbg/gdbdriver.cpp

kdbg/gdbdriver.cpp

diff --git a/kdbg/gdbdriver.cpp b/kdbg/gdbdriver.cpp
index f76f753..ac86016 100644
--- a/kdbg/gdbdriver.cpp
+++ b/kdbg/gdbdriver.cpp
@@ -282,6 +282,38 @@
 	return;
     }
 
+    switch (cmd->m_cmd) {
+    case DCinitialize:
+	{
+	    /*
+	     * 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);
 
a8abc774 2019-05-31 11:51:44 Johannes Sixt
Grok gdb 7's <incomplete sequence> marker in strings.

When a string ends in an incomplete multi-byte sequence, gdb adds an
<incomplete sequence...> fragment to the end of the string. Previously,
this resulted in a parse error and incomplete variable information.

Reported by Kevin Lemay.
(cherry picked from upstream commit 03da8a5ec97c8c7b125b2bd453d2f1c3a018d477)
M kdbg/gdbdriver.cpp
M kdbg/testprogs/testfile.cpp

kdbg/gdbdriver.cpp

diff --git a/kdbg/gdbdriver.cpp b/kdbg/gdbdriver.cpp
index ac86016..16efe9a 100644
--- a/kdbg/gdbdriver.cpp
+++ b/kdbg/gdbdriver.cpp
@@ -1048,7 +1048,8 @@
 	}
     }
     // is the string continued?
-    if (*p == ',') {
+    if (*p == ',')
+    {
 	// look ahead for another quote
 	const char* q = p+1;
 	while (isspace(*q))
@@ -1058,6 +1059,17 @@
 	    p = q;
 	    goto moreStrings;
 	}
+
+	// some strings can end in <incomplete sequence ...>
+	if (strncmp(q, "<incomplete sequence", 20) == 0)
+	{
+	    p = q+20;
+	    while (*p != '\0' && *p != '>')
+		p++;
+	    if (*p != '\0') {
+		p++;		/* skip the '>' */
+	    }
+	}
     }
     /* very long strings are followed by `...' */
     if (*p == '.' && p[1] == '.' && p[2] == '.') {

kdbg/testprogs/testfile.cpp

diff --git a/kdbg/testprogs/testfile.cpp b/kdbg/testprogs/testfile.cpp
index 884ddad..242c504 100644
--- a/kdbg/testprogs/testfile.cpp
+++ b/kdbg/testprogs/testfile.cpp
@@ -101,6 +101,25 @@
 template<typename F>
 void templated_strtest(F f, const char* t)
 {
+	// test <incomplete sequence> in various contexts
+	struct incomplete_seq_intern {
+		int val;
+		char is[4];
+		int val2;
+	};
+	struct incomplete_seq_end {
+		int val;
+		char is[4];
+	};
+	unsigned char a[4] = {',', 020, 021, 0325};
+	incomplete_seq_intern b = { 1, {',', 020, 021, 0325}, 2 };
+	incomplete_seq_end c = { 1, {',', 020, 021, 0325} };
+	unsigned char d[30][4] = { {',', 020, 021, 0325}, };
+	for (int i = 1; i < 30; i++)
+		memcpy(d[i], d[0], 4);
+	incomplete_seq_intern ba[30] = { { 1, {',', 020, 021, 0325}, 2 } };
+	incomplete_seq_end ca[30] = { { 1, {',', 020, 021, 0325} } };
+
 	f(t);
 }
 
26a2a759 2019-05-31 11:51:54 Johannes Sixt
Fix parsing of disassembly produced by gdb 7.1.

Since gdb 7.1, the address does not start at the beginning of a line, and
it can be prefixed by a pointer => that indicates the current instruction.
(cherry picked from upstream commit 5c5f34852d30337ef7c23ef4e88d50ecee1c0703)
M kdbg/gdbdriver.cpp

kdbg/gdbdriver.cpp

diff --git a/kdbg/gdbdriver.cpp b/kdbg/gdbdriver.cpp
index 16efe9a..933c191 100644
--- a/kdbg/gdbdriver.cpp
+++ b/kdbg/gdbdriver.cpp
@@ -2422,6 +2422,15 @@
     while (p != end)
     {
 	DisassembledCode c;
+	// skip initial space or PC pointer ("=>", since gdb 7.1)
+	while (p != end) {
+	    if (isspace(*p))
+		++p;
+	    else if (p[0] == '=' && p[1] == '>')
+		p += 2;
+	    else
+		break;
+	}
 	const char* start = p;
 	// address
 	while (p != end && !isspace(*p))
a6469516 2019-05-31 14:02:49 Johannes Sixt
Fix call of a member function dependent on a template parameter.

We must make the access of 'push_back' dependent, too. Otherwise, name
lookup does not find the name. Earlier compilers were more permissive and
did find the name.
(cherry picked from upstream commit 5f55847d441aba7742417e78c3b4fbe8344acc5e)
M kdbg/testprogs/std.cpp

kdbg/testprogs/std.cpp

diff --git a/kdbg/testprogs/std.cpp b/kdbg/testprogs/std.cpp
index af37a3a..f1865a9 100644
--- a/kdbg/testprogs/std.cpp
+++ b/kdbg/testprogs/std.cpp
@@ -13,7 +13,7 @@
 	V(const T& v) : std::vector<T>(10, v) {}
 	void anotherone(const T& v)
 	{
-		push_back(v);
+		this->push_back(v);
 	}
 };
 

Branch: r14.0.x

636663de 2019-05-31 13:32:08 Johannes Sixt
Grok gdb 7's <incomplete sequence> marker in strings.

When a string ends in an incomplete multi-byte sequence, gdb adds an
<incomplete sequence...> fragment to the end of the string. Previously,
this resulted in a parse error and incomplete variable information.

Reported by Kevin Lemay.
(cherry picked from upstream commit 03da8a5ec97c8c7b125b2bd453d2f1c3a018d477)

(cherry picked from commit a8abc77457cda320f7577c2da7d6d592aaac0ca6)
M kdbg/gdbdriver.cpp
M kdbg/testprogs/testfile.cpp

kdbg/gdbdriver.cpp

diff --git a/kdbg/gdbdriver.cpp b/kdbg/gdbdriver.cpp
index ac86016..16efe9a 100644
--- a/kdbg/gdbdriver.cpp
+++ b/kdbg/gdbdriver.cpp
@@ -1048,7 +1048,8 @@
 	}
     }
     // is the string continued?
-    if (*p == ',') {
+    if (*p == ',')
+    {
 	// look ahead for another quote
 	const char* q = p+1;
 	while (isspace(*q))
@@ -1058,6 +1059,17 @@
 	    p = q;
 	    goto moreStrings;
 	}
+
+	// some strings can end in <incomplete sequence ...>
+	if (strncmp(q, "<incomplete sequence", 20) == 0)
+	{
+	    p = q+20;
+	    while (*p != '\0' && *p != '>')
+		p++;
+	    if (*p != '\0') {
+		p++;		/* skip the '>' */
+	    }
+	}
     }
     /* very long strings are followed by `...' */
     if (*p == '.' && p[1] == '.' && p[2] == '.') {

kdbg/testprogs/testfile.cpp

diff --git a/kdbg/testprogs/testfile.cpp b/kdbg/testprogs/testfile.cpp
index 884ddad..242c504 100644
--- a/kdbg/testprogs/testfile.cpp
+++ b/kdbg/testprogs/testfile.cpp
@@ -101,6 +101,25 @@
 template<typename F>
 void templated_strtest(F f, const char* t)
 {
+	// test <incomplete sequence> in various contexts
+	struct incomplete_seq_intern {
+		int val;
+		char is[4];
+		int val2;
+	};
+	struct incomplete_seq_end {
+		int val;
+		char is[4];
+	};
+	unsigned char a[4] = {',', 020, 021, 0325};
+	incomplete_seq_intern b = { 1, {',', 020, 021, 0325}, 2 };
+	incomplete_seq_end c = { 1, {',', 020, 021, 0325} };
+	unsigned char d[30][4] = { {',', 020, 021, 0325}, };
+	for (int i = 1; i < 30; i++)
+		memcpy(d[i], d[0], 4);
+	incomplete_seq_intern ba[30] = { { 1, {',', 020, 021, 0325}, 2 } };
+	incomplete_seq_end ca[30] = { { 1, {',', 020, 021, 0325} } };
+
 	f(t);
 }
 
547472d5 2019-05-31 13:32:08 Johannes Sixt
Fix parsing of disassembly produced by gdb 7.1.

Since gdb 7.1, the address does not start at the beginning of a line, and
it can be prefixed by a pointer => that indicates the current instruction.
(cherry picked from upstream commit 5c5f34852d30337ef7c23ef4e88d50ecee1c0703)

(cherry picked from commit 26a2a7598846501d109da764020b082ce5394d76)
M kdbg/gdbdriver.cpp

kdbg/gdbdriver.cpp

diff --git a/kdbg/gdbdriver.cpp b/kdbg/gdbdriver.cpp
index 16efe9a..933c191 100644
--- a/kdbg/gdbdriver.cpp
+++ b/kdbg/gdbdriver.cpp
@@ -2422,6 +2422,15 @@
     while (p != end)
     {
** Diff limit reached (max: 250 lines) **
bbfa8704 2019-05-31 14:03:30 Johannes Sixt
Fix call of a member function dependent on a template parameter.

We must make the access of 'push_back' dependent, too. Otherwise, name
lookup does not find the name. Earlier compilers were more permissive and
did find the name.
(cherry picked from upstream commit 5f55847d441aba7742417e78c3b4fbe8344acc5e)

(cherry picked from commit a6469516e6494e9e314bd44cf4fa40a4faef36b6)
M kdbg/testprogs/std.cpp
** Diff limit reached (max: 250 lines) **