This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix -list-thread-groups --available logic and add test
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>
- Cc: Simon Marchi <simon dot marchi at ericsson dot com>, gdb-patches at sourceware dot org, tom at tromey dot com
- Date: Wed, 4 Oct 2017 15:42:07 +0100
- Subject: Re: [PATCH] Fix -list-thread-groups --available logic and add test
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 96258285B2
- References: <1507125639-522-1-git-send-email-simon.marchi@ericsson.com> <88d47cd0-df4e-84ea-e19d-0e6f7b0dc79b@redhat.com> <4b4d69ff72cd6840be87168174cb7181@polymtl.ca>
On 10/04/2017 03:32 PM, Simon Marchi wrote:
> On 2017-10-04 10:14, Pedro Alves wrote:
>> On 10/04/2017 03:00 PM, Simon Marchi wrote:
>>
>>> +# List a specific process.
>>> +set spawn_id [remote_spawn target $binfile]
>>> +set pid [spawn_id_get_pid $spawn_id]
>>> +mi_gdb_test \
>>> + "-list-thread-groups --available i${pid}" \
>>> + "\\^done,groups=\\\[{id=\"${pid}\",type=\"process\",.*}\\\]" \
>>> + "list available thread groups with filter"
>>
>> Won't that ".*" above end up matching more than one process, if
>> GDB's filtering ends up a bit borked? Can we be sure that
>> only one process comes out?
>
> I tried designing it like that but found it was pretty difficult because
> of the description field:
>
> 55
> ^done,groups=[{id="499",type="process",description="/home/emaisin/build/binutils-gdb/gdb/testsuite/outputs/gdb.mi/list-thread-groups-available/list-thread-groups-available",user="emaisin",cores=["1"]}]^M
>
>
> If we have something like this:
>
> groups=[{id="$decimal",type="process",description=".*",...}]
Instead of .*, how about matching "all but unquoted/terminating
double-quote" ?
See http://wiki.tcl.tk/989 for example (Match a "quoted string").
(Maybe there's an easier way to write that regex, haven't
really thought about it.)
>
> and there are two process entries, the .* in the description field could
> match from the beginning of the first description field to the end of
> the second description field. So we wouldn't catch that there are two
> processes instead of one. And we can't really restrict its content,
> because it could potentially include [,}"].
>
> Do you have any idea on how to do this with a regex? The only "real"
> solution I see is to have a proper MI parser that parses MI to a tcl
> data structure, and assert that the list of groups is of length 1.
A "real" parser would consume the "..." description string as a single
string by looking for an unescaped terminating double-quote. :-)
Thanks,
Pedro Alves