From 22198107157b32447cc73607f031f4ca1e34da89 Mon Sep 17 00:00:00 2001 From: Marcel Ball Date: Wed, 24 Jan 2018 15:47:23 -0400 Subject: [PATCH 1/3] Fix GDB expansion of structures/arrays containing floating point values. --- src/backend/gdb_expansion.ts | 2 +- test/gdb_expansion.test.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/backend/gdb_expansion.ts b/src/backend/gdb_expansion.ts index efb5949..8528dff 100644 --- a/src/backend/gdb_expansion.ts +++ b/src/backend/gdb_expansion.ts @@ -7,7 +7,7 @@ const referenceStringRegex = /^(0x[0-9a-fA-F]+\s*)"/; const referenceRegex = /^0x[0-9a-fA-F]+/; const nullpointerRegex = /^0x0+\b/; const charRegex = /^(\d+) ['"]/; -const numberRegex = /^\d+/; +const numberRegex = /^\d+(\.\d+)?/; const pointerCombineChar = "."; export function isExpandable(value: string): number { diff --git a/test/gdb_expansion.test.ts b/test/gdb_expansion.test.ts index 60acddf..8d7e3b7 100644 --- a/test/gdb_expansion.test.ts +++ b/test/gdb_expansion.test.ts @@ -292,4 +292,15 @@ suite("GDB Value Expansion", () => { } ]); }); + test("float values", () => { + let node = `{ intval1 = 123, floatval1 = 123.456, intval2 = 3, floatval2 = 234.45 }`; + let variables = expandValue(variableCreate, node); + + assert.deepEqual(variables, [ + { name: "intval1", value: "123", variablesReference: 0 }, + { name: "floatval1", value: "123.456", variablesReference: 0 }, + { name: "intval2", value: "3", variablesReference: 0 }, + { name: "floatval2", value: "234.45", variablesReference: 0 } + ]); + }); }); \ No newline at end of file From cdee9d64206d3cae46fe0b1852ab6791b833bea0 Mon Sep 17 00:00:00 2001 From: Marcel Ball Date: Wed, 24 Jan 2018 16:00:04 -0400 Subject: [PATCH 2/3] Fix bug with MI Parsing if there is a list with empty strings A JavaScript string is a falsy value - but an empty string is valid in these positions - so need to explicitly check for undefined instead of just falsy. --- src/backend/mi_parse.ts | 2 +- test/mi_parse.test.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/mi_parse.ts b/src/backend/mi_parse.ts index 76503c2..594ddf3 100644 --- a/src/backend/mi_parse.ts +++ b/src/backend/mi_parse.ts @@ -213,7 +213,7 @@ export function parseMI(output: string): MINode { let values = []; values.push(value); let remaining = output; - while (value = parseCommaValue()) + while ((value = parseCommaValue()) !== undefined) values.push(value); output = output.substr(1); // ] return values; diff --git a/test/mi_parse.test.ts b/test/mi_parse.test.ts index 69fc555..bf290b5 100644 --- a/test/mi_parse.test.ts +++ b/test/mi_parse.test.ts @@ -173,4 +173,9 @@ suite("MI Parse", () => { assert.equal(MINode.valueOf(obj[1], "@frame.fullname"), undefined); assert.equal(MINode.valueOf(obj[1], "@frame.line"), undefined); }); + test("empty string values", () => { + let parsed = parseMI(`15^done,register-names=["r0","pc","","xpsr","","control"]`); + let result = parsed.result('register-names'); + assert.deepEqual(result, ["r0", "pc", "", "xpsr", "", "control"]); + }); }); \ No newline at end of file From d827275613094d8d7d2b8b0bbe7a75ca4860b956 Mon Sep 17 00:00:00 2001 From: Marcel Ball Date: Wed, 24 Jan 2018 16:02:45 -0400 Subject: [PATCH 3/3] Fix an issue where an element of an array or struct changing will visually show the change on the containing array/struct. - Getting the change list from GDB will get changes from members. - Original code was mistakenly using the variable name from the outside object when looking up the handle to apply the changes instead of the variable name in the changelist. --- src/mibase.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mibase.ts b/src/mibase.ts index 0b623fd..a961a50 100644 --- a/src/mibase.ts +++ b/src/mibase.ts @@ -342,7 +342,7 @@ export class MI2DebugSession extends DebugSession { const changelist = changes.result("changelist"); changelist.forEach((change) => { const name = MINode.valueOf(change, "name"); - const vId = this.variableHandlesReverse[varObjName]; + const vId = this.variableHandlesReverse[name]; const v = this.variableHandles.get(vId) as any; v.applyChanges(change); });