Advertisement
Guest User

debugger edits process memory

a guest
Jan 17th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. me@oliphant:~$ cat lala.cpp
  2. #include <iostream>
  3. #include <unistd.h>>
  4.  
  5. int main(int argc, char** argv) {
  6. volatile int i(0);
  7.  
  8. while(true){
  9. std::cout << i << std::endl;
  10. sleep(5);
  11. }
  12. }
  13. me@oliphant:~$ g++ -ggdb lala.cpp
  14. me@oliphant:~$ ./a.out & gdb a.out $! -f a.out
  15. [1] 98933
  16. 0
  17. Excess command line arguments ignored. (a.out)
  18. GNU gdb 6.3.50-20050815 (Apple version gdb-1461.2) (Fri Mar 5 04:43:10 UTC 2010)
  19. Copyright 2004 Free Software Foundation, Inc.
  20. GDB is free software, covered by the GNU General Public License, and you are
  21. welcome to change it and/or distribute copies of it under certain conditions.
  22. Type "show copying" to see the conditions.
  23. There is absolutely no warranty for GDB. Type "show warranty" for details.
  24. This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ... done
  25.  
  26. /Users/me/98933: No such file or directory
  27. Attaching to program: `/Users/me/a.out', process 98933.
  28. Reading symbols for shared libraries ++. done
  29. 0x00007fff888b3a6a in __semwait_signal ()
  30. (gdb) break lala.cpp:9
  31. Breakpoint 1 at 0x100000d4b: file lala.cpp, line 9.
  32. (gdb) c
  33. Continuing.
  34. 0
  35.  
  36. Breakpoint 1, main (argc=1, argv=0x7fff5fbfef28) at lala.cpp:9
  37. /Users/me/lala.cpp:9:154:beg:0x100000d4b
  38. (gdb) print i=22
  39. $1 = 22
  40. (gdb) c
  41. Continuing.
  42. 22
  43.  
  44. Breakpoint 1, main (argc=1, argv=0x7fff5fbfef28) at lala.cpp:9
  45. /Users/me/lala.cpp:9:154:beg:0x100000d4b
  46. (gdb) The program is running. Quit anyway (and detach it)? (y or n) y
  47. Detaching from program: `/Users/me/a.out', process 98933.
  48. me@oliphant:~$ 22
  49. fg
  50. ./a.out
  51. 22
  52. ^C
  53. me@oliphant:~$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement