Fix the DynamicRegisterInfo::Dump() method to correctly assume that
the register numbers in value_regs and invalidate_regs arrays are
remote (eRegisterKindProcessPlugin) rather than local
(eRegisterKindLLDB). This fixes invalid memory references when the two
register numbers are not in sync.
Details
Diff Detail
Event Timeline
TestRemoteRegNums suggests that there's also code relying on remote regnums being used there. What a mess :-(.
Ok, I think it might just be Dump() being broken. I've found another bug with my code, and things seem to work after fixing it, so I suppose the problem is not really worth my effort right now.
Also updated the comments in struct RegisterInfo to indicate what kind of numbers go in these arrays.
I'm not sure if this is correct, or if I want it to be correct. I think that a lot of the confusion comes from the fact that this structure is used both in lldb-server and lldb, and I'm not sure that the fields have the same meaning in both cases (specifically, the "process plugin" concept is not really a thing in lldb-server). I think it would be better to standardize on the "lldb" numbers, as those should be available everywhere, but I may be forgetting some important issues. Omair may remember this in more detail.
This is complicated mainly because we are trying to merge two different register numbering scheme. On LLDB (host) side we try to construct register number from parsing register xml assigning register numbers in the increasing order. But we also have target supplied register numbers in regnum field. However registers on LLDB server side have fixed numbering although it may look like assigned in increasing order but this may not always be the case. Presence of optional register sets also doesnt help so we have the mess on managing target vs host register numbers not always in sync.
For invalidate_regs and value_regs register numbers should always be the ones assigned by remote i-e eRegisterKindProcessPlugin. So I would say this patch is ok as it corrects that info.
Broadly speaking we should do something about integrating user typed registers which may be unions of various other registers but should not require numbering.
clang-tidy: error: 'lldb/lldb-private.h' file not found [clang-diagnostic-error]
not useful