[PATCH v3 7/9] winedbg: Define table for GDB qXfer command handlers.

Rémi Bernon rbernon at codeweavers.com
Wed Nov 17 02:41:39 CST 2021


On 11/17/21 09:24, Jinoh Kang wrote:
> On 11/17/21 03:43, Rémi Bernon wrote:
>> On 11/16/21 17:51, Jinoh Kang wrote:
>>> Replace the series of sscanf in packet_query with a dedicated qXfer
>>> request parser function and a lookup into a predefined handler table.
>>>
>>> Signed-off-by: Jinoh Kang <jinoh.kang.kr at gmail.com>
>>> ---
>>>    programs/winedbg/gdbproxy.c | 218 ++++++++++++++++++++++++++----------
>>>    1 file changed, 160 insertions(+), 58 deletions(-)
>>>
>>
>> To be honest I find the sscanf version much more readable, especially as gdb protocol is not always easy to follow,
> 
> I do too.  It's just that I couldn't figure out how to keep sscanf (with its
> format specifiers) in the generalised parser.
> 
> The annex part of "libraries" and "threads" is always empty, but for
> "features" it is not.  Therefore, extracting the annex part requires matching
> a *possibly empty* sequence of characters in a desired character set.
> '%[]' can no longer be used, as it requires at least one character.
> 
> Any suggestions are welcome.
> 

What about having two cases like this?

> if (sscanf(gdbctx->in_packet, "Xfer:%256[^:]:read::%x,%x", topic, &off, &len) == 3 ||
>     sscanf(gdbctx->in_packet, "Xfer:%256[^:]:read:%256[^:]:%x,%x", topic, annex, &off, &len) == 4)

Or splitting the topic off, but I think having the patterns like this 
you can easily grasp how the protocol is supposed to be.
-- 
Rémi Bernon <rbernon at codeweavers.com>



More information about the wine-devel mailing list