http://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_118.html[/url]
[url]
http://visualgdb.com/gdbreference/commands/set_solib-search-path
[/url]
引用
root@jason:/opt/lxc/src/lxc# gdb ./lxc-attach
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./lxc-attach...done.
(gdb) set solib-search-path /opt/lxc/
aclocal.m4 autom4te.cache/ config.status CONTRIBUTING .git/ INSTALL lxc.spec Makefile NEWS templates/
AUTHORS config/ configure COPYING .gitignore lxc.pc lxc.spec.in Makefile.am README .travis.yml
autogen.sh config.log configure.ac doc/ hooks/ lxc.pc.in MAINTAINERS Makefile.in src/
(gdb) set solib-search-path /opt/lxc/src/lxc/
(gdb) b lxc_attach
Breakpoint 1 at 0x400b50
(gdb) run -n p2
Starting program: /opt/lxc/src/lxc/lxc-attach -n p2
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, lxc_attach (name=0x7fffffffe7a4 "p2", lxcpath=0x604070 "/usr/local/var/lib/lxc", exec_function=0x400b40 <lxc_attach_run_shell@plt>, exec_payload=exec_payload@entry=0x0,
options=options@entry=0x7fffffffe3d0, attached_process=attached_process@entry=0x7fffffffe3bc) at attach.c:695
695 {
(gdb) l
690 free(p);
691 return ret;
692 }
693
694 int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_function, void* exec_payload, lxc_attach_options_t* options, pid_t* attached_process)
695 {
696 int ret, status;
697 pid_t init_pid, pid, attached_pid, expected;
698 struct lxc_proc_context_info *init_ctx;
699 char* cwd;
(gdb) l
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x00007ffff7ddaae0 0x00007ffff7df54e0 Yes /lib64/ld-linux-x86-64.so.2
0x00007ffff7b768b0 0x00007ffff7bbd25c Yes /opt/lxc/src/lxc/liblxc.so
0x00007ffff77c24a0 0x00007ffff7907583 Yes /lib/x86_64-linux-gnu/libc.so.6
0x00007ffff75a0f10 0x00007ffff75a1804 Yes /lib/x86_64-linux-gnu/libutil.so.1
0x00007ffff73879f0 0x00007ffff73944a1 Yes /lib/x86_64-linux-gnu/libpthread.so.0