Re: Dejagnu testing issue

Kevin Pouget
2011-10-21T08:15:27Z

On Thu, Oct 20, 2011 at 5:02 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Kevin" == Kevin Pouget <kevin.pouget@gmail.com> writes:
>
> Kevin> how can I read a value from what GDB writes, and use it later to
> Kevin> validate some tests.
>
> Kevin> For instance, the pid:
>
> Kevin> I know it's it "info inferiors" --> ".*process HERE .*", I would like
> Kevin> to save it, and then do something like "detach", "attach $PID"
>
> Kevin> (don't get me wrong, I know there are some alternatives to get the
> Kevin> PID, but I really want to read it from a GDB command)
>
> You can do it, with some difficulty, using gdb_test_multiple and
> examining expect_out in your match.  This is done in some places in the
> code.

Thanks for your reponses (and sorry for posted on the wrong
mailing-list, it was supposed to go to gdb@sourceware.org)

for the record, here is the way to get the pid based on "expect_out":

gdb_test_multiple "info inferior" "list inferiors" {
-re ".* \* 1.*process (\[0-9\]*).*$gdb_prompt $" {
set pid $expect_out(1,string)
pass "list inferiors"
}
}

> Kevin> By the way, is it a normal that I can't set a thread breakpoint this way:
>
>>> break <somewhere> thread $_thread
>>> Junk after thread keyword.
>
> Kevin> (that would have bypassed the problem described above !)
>
> Yes, the 'thread' modifier just takes an integer.
> You can use eval though:
>
>    eval "break ... thread %d", $_thread

from a user point of view, it's not obvious why $_thread is not an
integer / what it actually is, but I guess there are some background
reasons. Anyway, output parsing and `eval' did the trick, thanks

Kevin

Kevin