Reputation: 3760
I've created a simple Varnish VMOD and I'd like to debug it using gdb
.
-g -O0
.gdb
and attach to the child Varnish process and set a breakpoint on my Varnish VMOD function name.No matter what I do, however, I cannot get the breakpoint to hit. I'm certain the VMOD is being executed as I can see output from it in the logs.
If my VMOD is called vmod_modifyparams
, should I just be able to b vmod_modifyparams
and have my breakpoint hit? Can I debug my custom Varnish VMOD in this fashion?
(gdb) b vmod_modifyparams
Function "vmod_modifyparams" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (vmod_modifyparams) pending.
(gdb) bt
#0 0x0000ffff8b76da54 in __GI___poll (fds=fds@entry=0xffffeefe83c0, nfds=nfds@entry=1, timeout=timeout@entry=-1) at ../sysdeps/unix/sysv/linux/poll.c:41
#1 0x0000aaaad5cf790c in poll (__timeout=-1, __nfds=1, __fds=0xffffeefe83c0) at /usr/include/aarch64-linux-gnu/bits/poll2.h:39
#2 VCLS_Poll (cs=0xaaaafc1074b0, cli=cli@entry=0xaaaafc1252c0, timeout=timeout@entry=-1) at ./lib/libvarnish/vcli_serve.c:607
#3 0x0000aaaad5c4c358 in CLI_Run () at cache/cache_cli.c:110
#4 0x0000aaaad5c6c034 in child_main (sigmagic=<optimized out>, altstksz=<optimized out>) at cache/cache_main.c:453
#5 0x0000aaaad5cb8e38 in mgt_launch_child (cli=cli@entry=0x0) at mgt/mgt_child.c:402
#6 0x0000aaaad5cba180 in MCH_Start_Child () at mgt/mgt_child.c:692
#7 0x0000aaaad5c3d454 in main (argc=<optimized out>, argv=<optimized out>) at mgt/mgt_main.c:1013
(gdb) s
__GI___pthread_disable_asynccancel (oldtype=0) at ./nptl/cancellation.c:66
66 ./nptl/cancellation.c: No such file or directory.
Upvotes: 0
Views: 37
Reputation: 3760
It turned out that my issue was not setting solib-search-path
correctly.
In a running Varnish instance the search path needs to be set to /var/lib/varnish/varnishd/vmod_cache
where the VMODs are cached and not /usr/lib/varnish/vmods
where the original shared objects are located.
Upvotes: 0
Reputation: 213879
I cannot get the breakpoint to hit
You may be attaching the wrong process.
One way to make sure it to use the "wait for debugger" technique from here or here. You could also print the process id from your function, so you know for sure you are attaching to the right process.
Upvotes: 0