summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Sixt <[email protected]>2010-11-30 22:47:40 +0100
committerSlávek Banko <[email protected]>2019-05-31 13:51:44 +0200
commita8abc77457cda320f7577c2da7d6d592aaac0ca6 (patch)
tree130d90dceae9d6e69844b4849409112eaae6791b
parenta57f5f7c68c0eaaf687952b4338012f1fbb51841 (diff)
downloadkdbg-a8abc77457cda320f7577c2da7d6d592aaac0ca6.tar.gz
kdbg-a8abc77457cda320f7577c2da7d6d592aaac0ca6.zip
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)
-rw-r--r--kdbg/gdbdriver.cpp14
-rw-r--r--kdbg/testprogs/testfile.cpp19
2 files changed, 32 insertions, 1 deletions
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 <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] == '.') {
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<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);
}