MSL2008. Debugging

862 views

Published on

Presentation about debugging done at Master on Free Software 2008 Edition

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
862
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

MSL2008. Debugging

  1. 1. Debugging Juan A. Suárez Romero <jasuarez@igalia.com> Master on Free Software
  2. 2. What is a bug? ● Basically, an error in a program ● When a program performs as it shouldn't perform ● All software have bugs – Programming is complex – Human task -> errors Master on Free Software
  3. 3. Type of bugs ● Resource-accessing bugs ● Semantic bugs – Wrong results – Unfullfil specifications ● Performance bugs ● Memory bugs – Overflows => crashes – Leaks ● Concurrent bugs Master on Free Software
  4. 4. Bugfixing ● Find a bug – By developers – By users ● Report a bug – Bugzilla ● Locate the problem – Debugging tools ● Fix it Master on Free Software
  5. 5. Finding bugs ● By developers – Compile-time errors are not bugs! – Running time ● By chance ● Running tests ● Using tools (see debugging) ● By users – They don't look for, but bugs turn up! – Reported to developers ● By testers – Mix between developers and users – Use more sophisticated techniques Master on Free Software
  6. 6. Reporting bugs ● Crash-report applications ● Bugtrackers: issue tracker system – Open a ticket (bug) – Add comments and/or other stuff – Tickets have states (life cycle) – Close ticket (bug) – Examples ● Bugzilla (from Mozilla Project) ● Mantis Bug Tracker Master on Free Software
  7. 7. Finding the problem ● To find something, we need to know about it – Develop small tests to reproduce the problem – Use debugging tools ● Debuggers ● Profilers ● Memory checkers ● ... Master on Free Software
  8. 8. Fixing bugs ● Using input from the last point ● Verify tests perform fine – Bug is fixed – Not introduce new bugs ● Document and commit Master on Free Software
  9. 9. Bugzilla ● Developed by Mozilla Foundation (1998) ● Web-based (LAMP) ● Widely used ● Highly configurable Master on Free Software
  10. 10. Bugzilla Master on Free Software
  11. 11. Bugzilla Master on Free Software
  12. 12. Bugzilla Where is the bug? Master on Free Software
  13. 13. Bugzilla Severity of bug ­ Blocker ­ Critical ­ Major ­ Normal ­ Minor Master on Free Software
  14. 14. Bugzilla Bug description ­ Overview ­ Preconditions ­ Steps to reproduce ­ Actual results ­ Expected results ­ Frequency ­ Other relevant information Master on Free Software
  15. 15. Bugzilla ● Priority: How urgent is to fix the bug? ● Differences between severity and priority – Severity is a technical matter – Priority is a business matter – Severity is absolute – Priority is relative – Priority can be calculated from severity Master on Free Software
  16. 16. Bugzilla Master on Free Software
  17. 17. Bugzilla Master on Free Software
  18. 18. Triagging ● Medical term: choose which patient would receive medical cares ● Useful when there are a lot of bugs, but few developers – Share bugs among developers – Use bug features and developers habilities to assign the bugs Master on Free Software
  19. 19. Bugzilla Master on Free Software
  20. 20. Bugzilla From Bugzilla  Documentation Master on Free Software
  21. 21. Some tools ● Printf ;-) ● GDB (GNU Debugger) ● Valgrind ● Electric Fence ● OProfile ● G_DEBUG (fatal_warnings, fatal_criticals) Master on Free Software
  22. 22. OProfile ● Profile all running code Master on Free Software
  23. 23. Electric Fence ● Find overflows / underflows ● Easy to use: preload/link against efence library ● Mark with “red zones” buffers – Crash inmediately when touching them – Thus, errors don't turn up in a future time Master on Free Software
  24. 24. G_DEBUG ● Useful to debug problems in Glib ● Environment variable – fatal_criticals: g_critical generates a core dump – fatal_warnings: g_warning generates a core dump Master on Free Software
  25. 25. Valgrind ● Tool suite for debugging and profiling ● Simulates a x86 processor – Memcheck: memory problems ● Memory accesses not allowed ● Memory leaks ● Bad frees – Cachegrind: cache profiler – Massif: heap profiler – Helgrind: thread debugger Master on Free Software
  26. 26. GDB ● GNU Debugger ● Text mode – Other frontends: IDEs, emacs, DDD, XXGDB ● Trace the code – See what is doing – Inspect the data Master on Free Software
  27. 27. GDB ● Requirements to debug an application – Add debugging symbols -> not stripped – Remove optimizations (-O0) Master on Free Software
  28. 28. GDB ● How to use – Run process with gdb – Inspect core dumps – Attach to running process Master on Free Software
  29. 29. Core dumps ● Dump of information of a process when it crashes – See while it crashed – Inspect data ● ulimit -c <size of core> ● ./gdb <program> <core> Master on Free Software
  30. 30. GDB ● Run: runs the program from start ● Continue: continues running a stopped program ● Backtrace: show the stack ● Break: add a breakpoint ● Delete: delete a breakpoint ● Next: runs the current line to next ● Step: same as Next, but if current is a function, enter inside ● Print: print the content of a variable ● Display: same as Print, but more permanent Master on Free Software
  31. 31. References ● http://www.google.es ● http://www.wikipedia.org ● http://www.bugzilla.org ● http://www.mantisbt.org ● http://library.gnome.org/devel/glib/unstable/glib-running.html ● http://sourceware.org/gdb/ ● http://oprofile.sourceforge.net ● http://valgrind.org Master on Free Software

×