MI and modifying register value
Tom Tromey
tom@tromey.com
Fri Sep 8 16:53:09 GMT 2023
>>>>> "Jan" == Jan Vrany via Gdb <gdb@sourceware.org> writes:
Jan> 1) There's an MI command to set register value: -data-write-register-values
Jan> This command is not documented and looking at the code, seems to be somewhat
Jan> half-implemented - does not use <format> parameter its comment mentions and
Jan> only works for frame 0 (but using --frame 1 does not result in an error,
Jan> it just silently changes value in frame 0).
Jan> Is this command some leftover that should not be used (but kept for some
Jan> old clients)? Or is it something to fix?
It's very old and seems to have landed without tests or documentation.
I think the addition of 'format' here must be some kind of copy-paste
bug. I can't imagine how it would be useful. However, in the spirit of
API conservatism I think it should just be left untouched -- we can just
document that it's a mistake and clients can send whatever they like for
this argument.
Fixing the frame bug seems completely fine to me.
Jan> 2) Another way to change register value is CLI command `set r4 = 0x4`. There's
Jan> no mechanism the MI client gets notified about the change - there's no =register-changed
Jan> async event.
Surely it must be "set $r4 = 0x4" -- the "$" should be needed I think.
Jan> Is this by purpose? I'd expect some kind of notification, just like there's =memory-changed
Jan> event. Also, in Python API, there's memory_ckanged event which get triggered when
Jan> using `set` to modify register.
There's the weird "-data-list-changed-registers" command. It doesn't
really documented "changed since what", but it seems to be "since last
time this was called". There's a static local variable in the
implementation :-(
I do see there is a "register_changed" observable, so implementing the
notification seems relatively easy. This observable seems to only track
changes made by the user, though.
Tom
More information about the Gdb
mailing list