Skip to content

Instantly share code, notes, and snippets.

@mikesart
Last active August 29, 2015 14:00
Show Gist options
  • Save mikesart/11274126 to your computer and use it in GitHub Desktop.
Save mikesart/11274126 to your computer and use it in GitHub Desktop.
Debugging Bash with Symbols vs. without
mikesart@mikesart-petra:~/dev/voglproj/vogl_chroot/vogl (vMcJohn-master)$ gdb --args /bin/bash
GNU gdb (GDB) 7.6.1-ubuntu
Source directories searched: /home/mikesart/src/eglibc-2.17/csu:/home/mikesart/src/eglibc-2.17/stdlib:...
Reading symbols from /bin/bash...Reading symbols from /usr/lib/debug/bin/bash...done.
(gdb) b parse_and_execute
Breakpoint 1 at 0x4722a0: file ../../bash/builtins/evalstring.c, line 174.
(gdb) dir ~/src/bash-4.2/bash-4.2/builtins
Source directories searched: /home/mikesart/src/bash-4.2/bash-4.2/builtins:/home/mikesart/src/eglibc-2.17/csu:/home/mikesart/src/eglibc-2.17/stdlib:/home/mikesart/src/eglibc-2.17/nss:/home/mikesart/src/eglibc-2.17/stdio-common:/home/mikesart/src/eglibc-2.17/malloc:/home/mikesart/src/eglibc-2.17/elf:/home/mikesart/src/eglibc-2.17/libio:/home/mikesart/src/eglibc-2.17/sysdeps:$cdir:$cwd
(gdb) r
Starting program: /bin/bash
Breakpoint 1, parse_and_execute (string=0x707008 "# System-wide .bashrc file for interactive bash(1) shells.\n...\n", from_file=from_file@entry=0x7064c8 "/etc/bash.bashrc", flags=flags@entry=20) at ../../bash/builtins/evalstring.c:174
(gdb) list
169 int
170 parse_and_execute (string, from_file, flags)
171 char *string;
172 const char *from_file;
173 int flags;
174 {
175 int code, lreset;
176 volatile int should_jump_to_top_level, last_result;
177 COMMAND *volatile command;
178
(gdb) bt
#0 parse_and_execute (string=0x707008 "# System-wide .bashrc file for interactive bash(1) shells.\n...", from_file=from_file@entry=0x7064c8 "/etc/bash.bashrc", flags=flags@entry=20) at ../../bash/builtins/evalstring.c:174
#1 0x0000000000471e73 in _evalfile (filename=filename@entry=0x7064c8 "/etc/bash.bashrc", flags=flags@entry=9) at ../../bash/builtins/evalfile.c:264
#2 0x0000000000472027 in maybe_execute_file (fname=fname@entry=0x4ab9ba "/etc/bash.bashrc", force_noninteractive=force_noninteractive@entry=1) at ../../bash/builtins/evalfile.c:312
#3 0x000000000041cd7d in run_startup_files () at ../bash/shell.c:1110
#4 main (argc=1, argv=0x7fffffffd928, env=0x7fffffffd938) at ../bash/shell.c:649
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment