Re: [PATCH 6/9] gdb/testsuite/dap: pass around dicts instead of ton objects

Simon Marchi via Gdb-patches
2023-01-26T03:29:27Z

On 1/25/23 17:04, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Simon> Change-Id: I2ca47bea355bf459090bae8680c6a917350b5c3f
>
> Probably could use a commit message.

Oops, that was a mistake. I always put at least a little something in
the commit messages, except for the extremely obvious commits.

> The main issue with this is that dicts lose type information from the
> JSON. So, if we ever need to check the type of some value sent by gdb,
> we won't be able to.

Ah, interesting.

> But I suppose we could always just add some new proc that returns the
> TON form and go from there. I don't recall if I've needed any such
> tests yet. Arguably maybe we should write one.

The idea of my change was that we currently did `namespace eval
ton::2dict` pretty much everywhere. So I thought it would be nice to
make it easier on callers and to the ton::2dict for them, that makes the
tests less verbose.

I think we can indeed add intermediary functions that return ton objects
as needed. For instance, have dap_request_and_response_ton can do most
of the work, and have dap_request_and_response be a small wrapper around
it to do the ton::2dict.

Based on this, my commit message would be:

The DAP helper functions generally return TON objects. However, callers
almost all immediately use ton::2dict to convert them to dicts, to
access their contents. This commits makes things a bit simpler for them
by having function return dicts directly instead.

The downside is that the TON objects contain type information. For
instance, a "2" in a TCL dict could have been the integer 2 or the
string "2" in JSON. By converting to TCL dicts, we lose that
information. If some tests specifically want to check the types of some
fields, I think we can add intermediary functions that return TON
objects, without having to complicate other callers who don't care.

Simon