Re: [PATCH] solib-svr4: Avoid unwanted shlib internal BPs When debugging Linux kernel or u-boot

Jan Kratochvil
2012-06-01T18:05:50Z

On Fri, 01 Jun 2012 18:21:28 +0200, Pedro Alves wrote:
> --- a/gdb/solib-svr4.c
> +++ b/gdb/solib-svr4.c
> @@ -1707,7 +1707,7 @@ enable_break (struct svr4_info *info, int from_tty)
> }
> }
>
> - if (!current_inferior ()->attach_flag)
> + if (interp_name != NULL && !current_inferior ()->attach_flag)
> {
> for (bkpt_namep = bkpt_names; *bkpt_namep != NULL; bkpt_namep++)
> {

It has a regression in the case below.

OTOH one has to strip _start to make it a regression as with _start GDB did not
catch startup libraries even before.

This is why I suggested to omit only "__start" and "_start" but not "main" if
INTERP_NAME == NULL.

But maybe so broken systems are not so common nowadays to still care about
them.

Regards,
Jan

==> 53.C <==
#include <dlfcn.h>
#include <assert.h>
#include <stdio.h>
static void *lib;
class C {
public:
C();
} c;
C::C() {
lib = dlopen ("./53l.so", RTLD_NOW);
assert(lib);
puts("opened");
}
int main () {
void (*fp)(void)=(void (*)(void))dlsym(lib,"l");
assert(fp);
fp();
}

==> 53l.C <==
#include <stdio.h>
class D {
public:
D();
} d;
D::D() {
puts ("in-library before-main");
}
extern "C" void l(void) {
puts ("in-library after-main");
}

$ ./gdb-unpatched ./53 -ex 'set breakpoint pending on' -ex 'b l' -ex run
Breakpoint 1, 0x00007ffff7dfd71e in l () from ./53l.so
(gdb) _

$ ./gdb-patched ./53 -ex 'set breakpoint pending on' -ex 'b l' -ex run
[Inferior 1 (process 2188) exited normally]
(gdb) _