When trying to add a breakpoint on a file from a shared library which has not yet been loaded, GDB prompts a y or [n] to make a pending breakpoint on future shared library. The result in gf is always [answered N; input not from terminal] and not making a breakpoint.
A similar situation occurs when sending kill into GDB except I get a GUI prompt to kill or cancel.
"Dumb" example to illustrate the problem:
main.c:
#include <dlfcn.h>
typedef void FooFunc(void *data);
int main(void)
{
void *foo_lib = dlopen("./libfoo.so", RTLD_NOW);
FooFunc *foo_func = dlsym(foo_lib, "foo_func");
char foo_data[1024] = {0};
for (int i = 0; i < 5; ++i) {
foo_func(foo_data);
}
dlclose(foo_lib);
}
foo.c:
struct Bar {
int state;
int the_variable;
};
void foo_func(void *data)
{
struct Bar *bar = data;
if (bar->state == 0) {
bar->state = 1;
bar->the_variable = 37;
}
++bar->the_variable;
}
When trying to add a breakpoint on a file from a shared library which has not yet been loaded, GDB prompts a
y or [n]
to make a pending breakpoint on future shared library. The result ingf
is always[answered N; input not from terminal]
and not making a breakpoint.A similar situation occurs when sending
kill
into GDB except I get a GUI prompt to kill or cancel."Dumb" example to illustrate the problem:
main.c
:foo.c
:build
:Try, for example, to break on
foo.c:10
before callingdlopen()
.