format of gdb remote P command with thread id suffix

Hey guys,

What would a gdb remote P command with a thread suffix look like when well formed? From RNBRemote::ExtractThreadIDFromThreadSuffix (…), it looks like it could be anywhere in the packet as I read HandlePacket_P(…).

Maybe this?
P{reg-index-hex}={value-hex}thread:{tid-hex}

Or is there an expectation of a semi after the value,
P{reg-index-hex}={value-hex};thread:{tid-hex}?

Thanks!

(Well not exactly anywhere - the HandlePacket_P would have already parsed out the P{reg-index-hex}={value-hex} portion, so the real question is how much content, if any, is expected to come between the end of the parsed hex value and the start of the “thread” keyword).

Hah ok forgot I have client code in LLDB I can look at. Got my answer. “…;thread:{tid-hex}” is what I needed (semi-colon separated).

Register read example:

$p0;thread:1cb556;#5e
$0000000000000000#00

Register write example:

$P4=00c0030001000000;thread:1cb773;#b7
$OK#00

Thanks, Greg!

It is easy to trigger these on MacOSX with:

(lldb) log enable gdb-remote packets
(lldb) file /bin/ls
(lldb) b malloc
(lldb) run

This will print out a register read packet. To trigger memory writes:

(lldb) p (int)puts("hello")

Then you will see some individual register writes from the expression parser.

Great, thanks Greg.