This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Using LD_PRELOAD in testsuite to extend gdb test coverage
- From: Yao Qi <yao at codesourcery dot com>
- To: Doug Evans <dje at google dot com>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Thu, 6 Mar 2014 14:23:26 +0800
- Subject: Re: Using LD_PRELOAD in testsuite to extend gdb test coverage
- Authentication-results: sourceware.org; auth=none
- References: <CADPb22QJ3=4U5KBYn5m6cmvH1rH=pvUdCcjpDDg76TGgWXPhxA at mail dot gmail dot com>
On 03/04/2014 11:40 AM, Doug Evans wrote:
> 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).
This kind of tests can be complementary to existing dejagnu-based test
cases, because dejagnu test cases are hard to drive GDB to a specific
state which is needed for testing.
>
> 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.
That sounds reasonable. FWIW, I used LD_PRELOAD mechanism to intercept
ptrace calls too to emulate that GDB is communicating with a remote
GDBserver or a slow jtag probe, in order to find performance issues when
GDB is talking with slow stubs.
>
> 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?
I can't figure out how much tests cases can/should be written in this
way. If only one or two test cases are written in this way, we can
start from a simple LD_PRELOAD library, and generalize it as needed
in the future.
--
Yao (éå)