Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Tools used for debugging

442 views

Published on

ldd, strace, ltrace, gdb

Published in: Software
  • Be the first to comment

  • Be the first to like this

Tools used for debugging

  1. 1. Debugging toolsDebugging tools Мариян HackMan Маринов <mm@1h.com>
  2. 2. Кой съм аз?Кой съм аз? ➢ Chief system architect of ➢ Sysadmin since the stone age ➢ The longest course in SoftUni Linux System Administration
  3. 3. What is this talk about?What is this talk about?
  4. 4. Debugging is twice as hard as writing the code inDebugging is twice as hard as writing the code in the first place.the first place. Therefore, if you write the code AS CLEVERLY ASTherefore, if you write the code AS CLEVERLY AS POSSIBLE, you are by DEFINITION, not smartPOSSIBLE, you are by DEFINITION, not smart enough to debug it.enough to debug it. -- Brian Kernighan-- Brian Kernighan
  5. 5. LDDLDD
  6. 6. $ ldd $ ldd -r $ ldd -v
  7. 7. STRACESTRACE
  8. 8. stracestrace -o logfile -f follow -s string size -p PID -n NUM
  9. 9. stracestrace -e trace=open (syscall) trace=file trace=network trace=desc
  10. 10. LTRACELTRACE
  11. 11. Nasty bugsNasty bugs
  12. 12. -o logfile -f follow -p PID -n 4 $ ltrace -n 4 sed -v -l library {[+-][symbol_pattern][@library_pattern]}
  13. 13. GDBGDB
  14. 14. GDB ­ GNU debuggerGDB ­ GNU debugger $ gcc -g$ gcc -g ➢ backtrace (bt)backtrace (bt) ➢ bt with core.dumpbt with core.dump ➢ frameframe ➢ printprint
  15. 15. GDB configurationGDB configuration ➢set follow-fork-mode childset follow-fork-mode child ➢parent - do not trace the childparent - do not trace the child ➢child - trace the child alsochild - trace the child also ➢ask - ask the userask - ask the user
  16. 16. GDB configurationGDB configuration Should we stop the trace after exec ?Should we stop the trace after exec ? ➢set follow-exec-mode newset follow-exec-mode new ➢ new - follow the new processnew - follow the new process ➢ same - keep the same processsame - keep the same process
  17. 17. GDB configurationGDB configuration Should we trace the child processes?Should we trace the child processes? ➢set detach-on-fork onset detach-on-fork on ➢ on - detach the child processon - detach the child process ➢ off - do not detachoff - do not detach
  18. 18. Въпроси?Въпроси? Мариян HackMan MarinovМариян HackMan Marinov E-Mail:E-Mail: mm@1h.commm@1h.com IRC: irc.freenode.net HackManIRC: irc.freenode.net HackMan ICQ: 7556201ICQ: 7556201 Jabber/Gtalk:Jabber/Gtalk: hackman@jabber.orghackman@jabber.org http://github.com/hackman/http://github.com/hackman/

×