When I'm running as root, using
But when I do the same thing as non-root,
How do I get
(Side note: I tried to use "gdb" as a tag, but the software insisted on making the tag "gdbe", whatever that is.)
gdb
(GNU gdb version 6.1.1 [FreeBSD]) is straightforward. Example:
Code:
root:/u/home/tmp# cat 1.c
#include <stdio.h>
void spain(void) {printf("got to spain\n");}
int main(void) { spain(); return 0; }
root:/u/home/tmp# cc -g -Wall -Werror 1.c -o 1
root:/u/home/tmp# 1
got to spain
root:/u/home/tmp# gdb 1
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
(gdb) b main
Breakpoint 1 at 0x40075f: file 1.c, line 3.
(gdb) b spain
Breakpoint 2 at 0x400740: file 1.c, line 2.
(gdb) run
Starting program: /u/home/tmp/1
Breakpoint 1, main () at 1.c:3
3 int main(void) { spain(); return 0; }
Current language: auto; currently minimal
(gdb) c
Continuing.
Breakpoint 2, spain () at 1.c:2
2 void spain(void) {printf("got to spain\n");}
(gdb) c
Continuing.
got to spain
Program exited normally.
(gdb) quit
root:/u/home/tmp#
gdb
can't seem to plant breakpoints:
Code:
home:~/tmp$ cat 1.c
#include <stdio.h>
void spain(void) {printf("got to spain\n");}
int main(void) { spain(); return 0; }
home:~/tmp$ cc -g -Wall -Werror 1.c -o 1
home:~/tmp$ 1
got to spain
home:~/tmp$ gdb 1
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
(gdb) b main
Breakpoint 1 at 0x40075f: file 1.c, line 3.
(gdb) b spain
Breakpoint 2 at 0x400740: file 1.c, line 2.
(gdb) run
Starting program: /u/home/tmp/1
Program received signal SIGTRAP, Trace/breakpoint trap.
0x0000000800602420 in ?? ()
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x000000080060b214 in ?? ()
(gdb) c
Continuing.
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb) quit
home:~/tmp$
gdb
to run as non-root? (Setting /usr/bin/gdb as suid root doesn't fix the problem.)(Side note: I tried to use "gdb" as a tag, but the software insisted on making the tag "gdbe", whatever that is.)