diff --git a/src/gdb/GDBDebugSessionBase.ts b/src/gdb/GDBDebugSessionBase.ts index 779b44d5..fe13eab5 100644 --- a/src/gdb/GDBDebugSessionBase.ts +++ b/src/gdb/GDBDebugSessionBase.ts @@ -18,6 +18,7 @@ import { Logger, logger, LoggingDebugSession, + MemoryEvent, OutputEvent, Scope, Source, @@ -3167,6 +3168,18 @@ export abstract class GDBDebugSessionBase extends LoggingDebugSession { case 'cmd-param-changed': this.handleCmdParamChanged(notifyData); break; + case 'memory-changed': { + let length = 0; + if (isNaN(notifyData.len)) { + logger.warn( + `GDB notify "memory-changed" has invalid length: ${notifyData.len}` + ); + } + length = parseInt(notifyData.len); + const memoryEvent = new MemoryEvent(notifyData.addr, 0, length); + this.sendEvent(memoryEvent); + break; + } default: logger.warn( `GDB unhandled notify: ${notifyClass}: ${JSON.stringify( diff --git a/src/integration-tests/mem.spec.ts b/src/integration-tests/mem.spec.ts index e41a3466..07b10de0 100644 --- a/src/integration-tests/mem.spec.ts +++ b/src/integration-tests/mem.spec.ts @@ -199,6 +199,26 @@ describe('Memory Test Suite', function () { verifyReadMemoryResponse(memory, newValue, addrOfArray); }); + it('can write memory and handle memory notifications from gdb', async function () { + const addrOfArray = parseInt( + ( + await dc.evaluateRequest({ + expression: '&array[0]', + frameId: frame.id, + }) + ).body.result + ); + const memoryEvent = dc.waitForEvent('memory'); + await dc.evaluateRequest({ + expression: '>set array[0] = 0xde', + frameId: frame.id, + context: 'repl', + }); + const output = await memoryEvent; + expect(parseInt(output.body.memoryReference)).eq(addrOfArray); + expect(output.body.count).eq(1); + }); + it('fails when trying to write to read-only memory', async function () { const addrOfArray = parseInt( (