Re: [RFC/PATCH] Add new internal variable $_signo

Pedro Alves
2013-06-17T17:10:45Z

On 06/16/2013 06:56 AM, Sergio Durigan Junior wrote:
>
>> > BTW, IMO, $_exitcode (and $_exitsignal) should print the exit
>> > code/signal of the selected inferior. It was never adjusted
>> > for multi-inferior, so it always prints the exit code of the
>> > inferior that happened to exit last. Simon's patch for
>> > displaying the inferior's exit-code in MI's -list-thread-groups records
>> > the info in the inferior struct. Once that is in, we'd just need to
>> > make $_exitcode a lazy convenience var too.
> OK, this paragraph mades sense but made me feel a bit confused.

Ok, that clarify. Say:

- you're running 100 inferiors under GDB in non-stop mode.
- they're all running (c -a&) while you're inspecting, say
thread #3 of inferior #1.
- inferiors #4, #65 and #87 exit, with exit codes 10, 20, 30,
respectively.
- '$_exitcode' is left set to '30', the exit code of inferior #87:

(gdb) p $_exitcode
$1 = 30
(gdb) inferior 4
(gdb) p $_exitcode
$2 = 30
(gdb) inferior 65
(gdb) p $_exitcode
$3 = 30
(gdb) inferior 87
(gdb) p $_exitcode
$4 = 30

Meaning, $_exitcode is useless when you consider async debugging,
as it may be overwritten at any point in time.

I was saying that IMO it'd make more sense that GDB behaved like
this instead:

(gdb) p $_exitcode
$1 = void
(gdb) inferior 4
(gdb) p $_exitcode
$2 = 10
(gdb) inferior 65
(gdb) p $_exitcode
$3 = 20
(gdb) inferior 87
(gdb) p $_exitcode
$4 = 30
(gdb) inferior 4
(gdb) p $_exitcode
$5 = 10

And that means making the $_exitcode convenience var a lazy
convenience var that prints 'struct inferior'::exit_code,
instead of a regular convenience var that gets set whenever
an inferior exits.

--
Pedro Alves