home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.bsd
- Path: sparky!uunet!wupost!usc!venice!gumby.dsd.trw.com!eel.dsd.trw.com!gottloeb
- From: gottloeb@eel.dsd.trw.com
- Subject: GDB under 386bsd 0.1
- Message-ID: <1992Sep4.005417.3876@gumby.dsd.trw.com>
- Originator: gottloeb@eel.dsd.trw.com
- Keywords: gdb, ptrace
- Sender: news@gumby.dsd.trw.com
- Reply-To: gottloeb@eel.dsd.trw.com
- Organization: TRW Space & Defense
- Date: Fri, 4 Sep 1992 00:54:17 GMT
- Lines: 56
-
- I have noticed a problem using gdb under 386bsd 0.1.
-
- When at least one breakpoint has been set and the program terminates,
- e.g. executes exit(), the breakpoint is not removed from the process's
- text image. When the program is subsequently re-executed under gdb,
- gdb remembers that a breakpoint is supposed to at the memory location
- and puts one there again. However this time it shadows the breakpoint
- instruction from the previous run rather than the original instruction.
- When execution begins after reaching the breakpoint, various traps occur.
-
- If the program is run after quitting gdb, a Trace/BPT trap occurs.
-
- I think the problem is that gdb assumes that when ptrace modifies the
- process's image the kernel either makes a private copy of the text image
- or it will throw away the text image after the process terminates.
- However, this is not the case - the kernel keeps the modified text image
- around and executes it rather than a fresh copy from the original file.
-
- This can be demonstrated with the following program:
-
-
- #include <stdio.h>
-
- void main() {
- printf("hello world\n");
- exit(1);
- }
-
-
- Compile the program:
- cc -g main.c
-
- Start gdb
- gdb a.out
-
- Set a breakpoint at the first line in main:
- break main
-
- Start program execution:
- run
-
- Continue program execution:
- cont
-
- Quit gdb
-
- Execute the program again:
- a.out
-
-
- Does anybody have a fix or any suggestions on how to fix this?
-
-
- Thanks in advance,
- Jeff Gottloeb
- gottloeb@gumby.dsd.trw.com
-