Re: [PATCH v2 42/47] gdb_test_multiple: Anchor prompt match if -lbl

Pedro Alves
2025-05-27T23:21:20Z

Ever stepped away from the computer for a few minutes, and had a D'oh! moment? Just happened here.

On 2025-05-27 23:41, Pedro Alves wrote:

> This idea of replacing GDB with a script is super interesting. Did you consider writing that script
> in tcl/expect, though? Seems like it would be a perfect fit. Read input, match against pattern, print
> output. :-P Another alternative would be to write a bit of GDB python to register a new command, and
> run the real GDB with that. But a script like you came up with mocking GDB completely is nice, it's
> very light and more decoupled.

Somehow I didn't recall that we can define commands in the CLI with "define foo". :-)

I think the best & simplest in this case is to do just that. Like, put this in a gdb script (*):

define command
echo prefix \n
echo prefix foo\n
echo prefix bar\n
echo prefix \n
end

then run the testcase with GDB as normal, load the script, and use gdb_test_multiple, all as usual.

I can take care of that.

* - or invoke "define" manually with gdb_test/gdb_test_multiple like some testcases do.

Pedro Alves