c - gdb doesn't stop on breakpoint -
i'm trying debug shared library run under check in unit-testing scenario. shared library statically linked (no dlload
) , both unit-testing application , shared library compiled debugging symbols (-g
)
in gdb
want set breakpoint in function contained in shared library. set breakpoint successfully, when runs passes on break-point.
what i've tried already:
i placed printf
in shared library, printed out, function called.
here's makefile i'm using compilation:
shell = /bin/sh cc = gcc cflags = -g -wall -std=gnu99 -iinclude extra_flags = -fpic -shared libflags = -fpic -shared ldflags = -shared -pthread -lcheck debugflags = -o0 -d _debug releaseflags = -o2 -d ndebug -combine -fwhole-program test_ldflags = -lcheck -lllist -llib -wl,-rpath $(objdir) objdir = lib target = $(objdir)/libllist.so test_target = starttest sources = $(shell echo src/*.c) headers = $(shell echo inc/*.h) test_sources = $(shell echo tests/*.c) test_objects = $(test_sources:.c=.o) objects = $(sources:.c=.o) prefix = $(destdir)/usr/local bindir = $(prefix)/bin all: $(target) tests $(target): $(objects) mkdir -p $(objdir) $(cc) $(flags) $(libflags) $(debugflags) -o $(target) $(objects) tests: $(test_objects) $(cc) $(flags) -o $(test_target) $(test_objects) $(test_ldflags) # need special rule compile lib allow extra_flags $(objects): $(sources) @echo [compiling]: $< $(cc) $(cflags) $(extra_flags) -o $@ -c $< clean: rm -rf $(test_objects) $(objects) *~ $(target) $(test_target) runtests: ./$(test_target)
i don't know specifics of check
framework using, such frameworks execute code-under-test in child process. if check
that, behavior expected -- debugging parent process, code executes in child.
you can confirm guess: replace printf
in code abort
. if gdb doesn't stop on sigabrt
, guess correct, , you'll want (gdb) set follow-fork-mode child
.
alternatively, read on multi-inferior debugging. can ask gdb debug both parent , child set detach-on-fork off
(documentation).
Comments
Post a Comment