home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / bsd / 5090 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.9 KB  |  70 lines

  1. Newsgroups: comp.unix.bsd
  2. Path: sparky!uunet!wupost!usc!venice!gumby.dsd.trw.com!eel.dsd.trw.com!gottloeb
  3. From: gottloeb@eel.dsd.trw.com
  4. Subject: GDB under 386bsd 0.1
  5. Message-ID: <1992Sep4.005417.3876@gumby.dsd.trw.com>
  6. Originator: gottloeb@eel.dsd.trw.com
  7. Keywords: gdb, ptrace
  8. Sender: news@gumby.dsd.trw.com
  9. Reply-To: gottloeb@eel.dsd.trw.com
  10. Organization: TRW Space & Defense
  11. Date: Fri, 4 Sep 1992 00:54:17 GMT
  12. Lines: 56
  13.  
  14. I have noticed a problem using gdb under 386bsd 0.1.
  15.  
  16. When at least one breakpoint has been set and the program terminates,
  17. e.g. executes exit(), the breakpoint is not removed from the process's
  18. text image.  When the program is subsequently re-executed under gdb,
  19. gdb remembers that a breakpoint is supposed to at the memory location
  20. and puts one there again.  However this time it shadows the breakpoint
  21. instruction from the previous run rather than the original instruction.
  22. When execution begins after reaching the breakpoint, various traps occur.
  23.  
  24. If the program is run after quitting gdb, a Trace/BPT trap occurs.
  25.  
  26. I think the problem is that gdb assumes that when ptrace modifies the
  27. process's image the kernel either makes a private copy of the text image
  28. or it will throw away the text image after the process terminates.
  29. However, this is not the case - the kernel keeps the modified text image
  30. around and executes it rather than a fresh copy from the original file.
  31.  
  32. This can be demonstrated with the following program:
  33.  
  34.  
  35. #include <stdio.h>
  36.  
  37. void main() {
  38.     printf("hello world\n");
  39.     exit(1);
  40. }
  41.  
  42.  
  43. Compile the program:
  44.     cc -g main.c
  45.  
  46. Start gdb
  47.     gdb a.out
  48.  
  49. Set a breakpoint at the first line in main:
  50.     break main
  51.  
  52. Start program execution:
  53.     run
  54.  
  55. Continue program execution:
  56.     cont
  57.  
  58. Quit gdb
  59.  
  60. Execute the program again:
  61.     a.out
  62.  
  63.  
  64. Does anybody have a fix or any suggestions on how to fix this?
  65.  
  66.  
  67. Thanks in advance,
  68. Jeff Gottloeb
  69. gottloeb@gumby.dsd.trw.com
  70.