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)
pull/3/head
Johannes Sixt 14 years ago committed by Slávek Banko
parent a57f5f7c68
commit a8abc77457
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -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] == '.') {

@ -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);
}

Loading…
Cancel
Save