This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using LD_PRELOAD in testsuite to extend gdb test coverage


Hi.

Sometimes I've wanted to write tests that are hard to write because
they greatly depend on the timing of things.  E.g., I need the
inferior in a particular state when a particular ptrace call from gdb
is made.

I wrote a prototype that lets me experiment with this.
It gives me quite a bit of flexibility, but it's not suitable for
checking into gdb.
I'd like to come up with something that I can check in.

My current motivation for this is an example that arose today where
gdb doesn't properly handle attaching to a program where a thread dies
before gdb can attach to it.  With this library, preloaded into gdb, I
can intercept ptrace calls (and others as needed) and, e.g., delay
them until the library detects the inferior is in the desired state
(arranged by however the library and the testcase wish to do so).

For implementation, I envision a .c file that contains all the
administrivia needed by an LD_PRELOAD library, plus some hooks that
let a .c provided by the testcase easily use it.  Then link the two
into the LD_PRELOAD library.

Obviously, such tests would only work on appropriate systems, but I
think providing a means to easily write such tests on such systems is
important enough.
If it's not a lot of code (my prototype is pretty straightforward),
and it provides a means to more easily test such cases, why not do it?

Comments?

If there are no objections to the basic idea, I'll work on and submit
a patch for further discussion.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]