From a8abc77457cda320f7577c2da7d6d592aaac0ca6 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Tue, 30 Nov 2010 22:47:40 +0100 Subject: Grok gdb 7's marker in strings. When a string ends in an incomplete multi-byte sequence, gdb adds an 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) --- kdbg/gdbdriver.cpp | 14 +++++++++++++- kdbg/testprogs/testfile.cpp | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) 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 @@ moreStrings: } } // 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 @@ moreStrings: p = q; goto moreStrings; } + + // some strings can end in + if (strncmp(q, "' */ + } + } } /* very long strings are followed by `...' */ if (*p == '.' && p[1] == '.' && p[2] == '.') { 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 @@ void strtest(const char* t) template void templated_strtest(F f, const char* t) { + // test 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); } -- cgit v1.2.3