public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* GDB testsuite questions
@ 2014-11-11 18:01 David Taylor
  2014-11-11 19:01 ` Simon Marchi
  2014-11-11 20:08 ` Andreas Schwab
  0 siblings, 2 replies; 4+ messages in thread
From: David Taylor @ 2014-11-11 18:01 UTC (permalink / raw)
  To: gdb

It's been more than a decade since I did anything significant in DejaGNU
or Tcl (and I've never really cared for Tcl as a language), so these
questions are probably easy for someone who uses it regularly.

I have two sets of changes to GDB held up while I figure these out --

. how to grab part of the each of the responses to multiple gdb commands
and do arithmetric on the result to decide whether the test failed or
passed.

More specifically testing a fix for bug 17520 (structure offset wrong
when 1/4 GB or greater).

While more of our structures are 'reasonably' sized, a few are rather
large.  If you have a structure where some members are 1/4 GB or more
bytes from the start of the structure, GDB will calculate the wrong
offset for the member.

So, given the structure:

    struct big_struct
    {
      char first[0x10000000 + 16];
      long second;
    } big_struct;

in GDB 7.8, I did:

   (gdb) print &big_struct
    $1 = (struct big_struct *) 0x601040 <big_struct>
    (gdb) print &big_struct.second
    $2 = (long *) 0xfffffffff0601050

So, I want to take the addresses and compare the difference vs what it
should be.

. I also need to be able to disable it for targets that don't have
enough memory.  The program does not need to be downloaded or run; but,
if the link fails, disable the test.

As part of the bug fix a total of 33 files were modified.  There are no
regressions on x86-64 Linux, but there needs to be a new test to make
sure the problem does not reoccur.

The other set of changes that is yet to be submitted for approval
involves extending the agent bytecode expressions to allow setting
variables (useful when a breakpoint is hit).  How do I force the
testsuite to run against gdbserver?  I have gdbserver changes and I want
them tested.  I also need to write the new tests...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GDB testsuite questions
  2014-11-11 18:01 GDB testsuite questions David Taylor
@ 2014-11-11 19:01 ` Simon Marchi
  2014-11-11 20:08 ` Andreas Schwab
  1 sibling, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2014-11-11 19:01 UTC (permalink / raw)
  To: David Taylor, gdb

Hi David,

On 2014-11-11 01:01 PM, David Taylor wrote:
> It's been more than a decade since I did anything significant in DejaGNU
> or Tcl (and I've never really cared for Tcl as a language), so these
> questions are probably easy for someone who uses it regularly.
> 
> I have two sets of changes to GDB held up while I figure these out --
> 
> . how to grab part of the each of the responses to multiple gdb commands
> and do arithmetric on the result to decide whether the test failed or
> passed.
> 
> More specifically testing a fix for bug 17520 (structure offset wrong
> when 1/4 GB or greater).
> 
> While more of our structures are 'reasonably' sized, a few are rather
> large.  If you have a structure where some members are 1/4 GB or more
> bytes from the start of the structure, GDB will calculate the wrong
> offset for the member.
> 
> So, given the structure:
> 
>     struct big_struct
>     {
>       char first[0x10000000 + 16];
>       long second;
>     } big_struct;
> 
> in GDB 7.8, I did:
> 
>    (gdb) print &big_struct
>     $1 = (struct big_struct *) 0x601040 <big_struct>
>     (gdb) print &big_struct.second
>     $2 = (long *) 0xfffffffff0601050
> 
> So, I want to take the addresses and compare the difference vs what it
> should be.

I don't know how to capture part of the output of a test to a tcl variable,
so you'll have to wait for someone else to answer that.

You could use something like the following command, which should be easy to
test with a single gdb_test.

    (gdb) p/x ((void *) &big_struct.second) - ((void *) &big_struct)
    $2 = 0xfffffffff0000010

However, it would still be nice to test it the way you suggested (get both
addresses and subtract in tcl), since my way involves the gdb code for
subtracting pointers, which is also subject to bugs related to big numbers.

> . I also need to be able to disable it for targets that don't have
> enough memory.  The program does not need to be downloaded or run; but,
> if the link fails, disable the test.

I suppose you are using prepare_for_testing at the beginning of your test.
If so, if you use it as many other tests do:

    if {[prepare_for_testing $testfile.exp $testfile $srcfile $compile_flags]} {
        untested $testfile.exp
        return -1
    }

then it will skip the test in the event of a build error.

> As part of the bug fix a total of 33 files were modified.  There are no
> regressions on x86-64 Linux, but there needs to be a new test to make
> sure the problem does not reoccur.

Indeed!

> The other set of changes that is yet to be submitted for approval
> involves extending the agent bytecode expressions to allow setting
> variables (useful when a breakpoint is hit).  How do I force the
> testsuite to run against gdbserver?  I have gdbserver changes and I want
> them tested.  I also need to write the new tests...

If you are asking how to run the tests with gdbserver, you can refer to this:
https://sourceware.org/gdb/wiki/TestingGDB#Testing_gdbserver_in_a_native_configuration

which in turns points you to the header of gdb/testsuite/boards/native-gdbserver.exp.

If you want to limit the scope of your test (only run it when using a remote target),
you can use "is_remote". There are plenty of examples in the testsuite.

If you want to limit the scope to _gdbserver_ specifically (and not any remote), then
it's a bit more tricky. There is an example of it in gdb.trace/qtro.exp. I have submitted
a patch some time ago about introducing a "target_is_gdbserver" procedure, which would
take care of that for you [1], but it's still pending.

Simon

[1] https://sourceware.org/ml/gdb-patches/2014-09/msg00697.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GDB testsuite questions
  2014-11-11 18:01 GDB testsuite questions David Taylor
  2014-11-11 19:01 ` Simon Marchi
@ 2014-11-11 20:08 ` Andreas Schwab
  2014-11-13 23:21   ` Doug Evans
  1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2014-11-11 20:08 UTC (permalink / raw)
  To: David Taylor; +Cc: gdb

David Taylor <dtaylor@emc.com> writes:

> . how to grab part of the each of the responses to multiple gdb commands
> and do arithmetric on the result to decide whether the test failed or
> passed.

Use the expect_out variable, there are various examples of its use in
the testsuite.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GDB testsuite questions
  2014-11-11 20:08 ` Andreas Schwab
@ 2014-11-13 23:21   ` Doug Evans
  0 siblings, 0 replies; 4+ messages in thread
From: Doug Evans @ 2014-11-13 23:21 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: David Taylor, gdb

On Tue, Nov 11, 2014 at 12:08 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> David Taylor <dtaylor@emc.com> writes:
>
>> . how to grab part of the each of the responses to multiple gdb commands
>> and do arithmetric on the result to decide whether the test failed or
>> passed.
>
> Use the expect_out variable, there are various examples of its use in
> the testsuite.

Yeah.  testsuite/lib/gdb.exp:get_integer_valueof is my canonical
example when I need boilerplate to cut-n-paste from.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-11-13 23:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-11 18:01 GDB testsuite questions David Taylor
2014-11-11 19:01 ` Simon Marchi
2014-11-11 20:08 ` Andreas Schwab
2014-11-13 23:21   ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).