diff --git a/src/MIParser.ts b/src/MIParser.ts index c45b64ad..4e2f060d 100644 --- a/src/MIParser.ts +++ b/src/MIParser.ts @@ -177,15 +177,27 @@ export class MIParser { const result: any = {}; if (c === '{') { c = this.next(); - while (c !== '}') { - if (c !== ',') { - this.back(); + if (c !== '"') { + // oject contains name-value pairs + while (c !== '}') { + if (c !== ',') { + this.back(); + } + const name = this.handleString(); + if (this.next() === '=') { + result[name] = this.handleValue(); + } + c = this.next(); } - const name = this.handleString(); - if (this.next() === '=') { - result[name] = this.handleValue(); + } else { + // "object" contains just values + this.back(); + let key = 0; + while (c !== '}') { + let value = this.handleCString(); + if (value) result[key++] = value; + c = this.next(); } - c = this.next(); } } diff --git a/src/integration-tests/miparser.spec.ts b/src/integration-tests/miparser.spec.ts index 07d705c8..2a9f2679 100644 --- a/src/integration-tests/miparser.spec.ts +++ b/src/integration-tests/miparser.spec.ts @@ -154,4 +154,23 @@ describe('MI Parser Test Suite', function () { 'stdout' ); }); + + it('structure that starts with a curly bracket and contains values but not keys', async function () { + parser.parseLine( + '+message,bkpt={number="1",type="breakpoint",thread-groups=["i1"],script={"p }123","p 321","p 789"}}' + ); + sinon.assert.calledOnceWithExactly( + gdbBackendMock.emit as sinon.SinonStub, + 'statusAsync', + 'message', + { + bkpt: { + number: '1', + type: 'breakpoint', + 'thread-groups': ['i1'], + script: { '0': 'p }123', '1': 'p 321', '2': 'p 789' }, + }, + } + ); + }); });