|
| 1 | +## Debugging errors: Run-time errors {#runtimeerr} |
| 2 | + |
| 3 | +_Skeleton descriptions are typeset in italic text,_ |
| 4 | +_so please don't remove these descriptions when editing the topic._ |
| 5 | + |
| 6 | +### Overview |
| 7 | + |
| 8 | +_Provides a short natural language abstract of the module’s contents._ |
| 9 | +_Specifies the different levels of teaching._ |
| 10 | + |
| 11 | +------------------------------------------------------------------------ |
| 12 | +Level Objective |
| 13 | +----------------- ------------------------------------------------------ |
| 14 | +Foundational Identifying the run-time error cause |
| 15 | + |
| 16 | +Main Introspection methodologies to trackdown run-time errors |
| 17 | + |
| 18 | +Advanced --- |
| 19 | + |
| 20 | +------------------------------------------------------------------------ |
| 21 | + |
| 22 | +### Motivation |
| 23 | + |
| 24 | +_Why is this important?_ |
| 25 | +_Why do we want to learn/teach this topic?_ |
| 26 | + |
| 27 | +Code correctness is important, as erroneous programs can lead to real-world catastrophes, take for example, medical equipment failures that lead to people being exposed to too much radiation. |
| 28 | +Techniques, such as, testing or fuzzing, help developers to identify erroneous states of the program. |
| 29 | +However, when these techniques discover a run-time error, it’s up to the programmer to reason about and find the root cause of such run-time errors, so they need a well established process to debug run-time errors. |
| 30 | + |
| 31 | +### Topic introduction |
| 32 | + |
| 33 | +_Very brief introduction to the topic._ |
| 34 | + |
| 35 | +There exists a wide variety of methodologies, techniques, and tools to debug run-time errors. |
| 36 | +In this topic, we give an overview of these and highlight how they can be applied to track down run-time errors in C++ programs. |
| 37 | + |
| 38 | +### Foundational: Identifying the run-time error cause {#runtimeerr-found} |
| 39 | + |
| 40 | +#### Background/Required Knowledge |
| 41 | + |
| 42 | +A student: |
| 43 | + |
| 44 | +* should be able to produce a basic running program. |
| 45 | + |
| 46 | +#### Student outcomes |
| 47 | + |
| 48 | +_A list of things "a student should be able to" after the curriculum._ |
| 49 | +_The next word should be an action word and testable in an exam._ |
| 50 | +_Max 5 items._ |
| 51 | + |
| 52 | +A student should be able to: |
| 53 | + |
| 54 | +1. verify the output of the program and identify incorrect outcomes. |
| 55 | +2. phrase hypothesis what could cause the run-time error. |
| 56 | +3. observe and extract program state at specific points of the program, to verify hypotheses. |
| 57 | +4. make their program as observable as possible. |
| 58 | + |
| 59 | +#### Caveats |
| 60 | + |
| 61 | +_This section mentions subtle points to understand, like anything resulting in |
| 62 | +implementation-defined, unspecified, or undefined behavior._ |
| 63 | + |
| 64 | +* run-time debugging can be domain specific |
| 65 | +* not everything about the program state can be easily observed, students should be aware of that and learn basic techniques to make programs more observable |
| 66 | +* students should be aware that the compilation mode (optimized vs debug) affects the debugging experience and also the program state itself |
| 67 | + |
| 68 | + |
| 69 | +#### Points to cover |
| 70 | + |
| 71 | +_This section lists important details for each point._ |
| 72 | + |
| 73 | +* the basics of using a debugger |
| 74 | +* compiling with debug information |
| 75 | +* observability techniques, such as, logging output or even `printf` statements |
| 76 | + |
| 77 | +### Main: Introspection methodologies to trackdown run-time errors {#runtimeerr-main} |
| 78 | + |
| 79 | +#### Background/Required Knowledge |
| 80 | + |
| 81 | +* All of the above. |
| 82 | + |
| 83 | +#### Student outcomes |
| 84 | + |
| 85 | +A student should be able to: |
| 86 | + |
| 87 | +1. use a debugger to inspect and manipulate program state |
| 88 | +2. extract crash information using proper libraries |
| 89 | +3. can create a minimal reproducible example |
| 90 | + |
| 91 | +#### Caveats |
| 92 | + |
| 93 | +* Different forms of multiprocessing programs can have varying impact on debuggability, such as: |
| 94 | + * parallel stl algorithms |
| 95 | + * multi threading |
| 96 | + * coroutines |
| 97 | + * vector parallelism |
| 98 | + |
| 99 | + |
| 100 | +#### Points to cover |
| 101 | + |
| 102 | +* How to use debuggers and the multitude of features they offer to manipulate and observe program state (e.g., break points, trap points, stack traces, manipulating program state). |
| 103 | +* Use (non) standard library support for crash information extraction, e.g., logging libraries, libraries to capture crash reports, and sanitizer libraries (asan/ubsan/tsan). |
| 104 | +* Creating minimal reproducible example and regressions tests from the extracted crash information. |
| 105 | + |
| 106 | + |
| 107 | +### Advanced {#runtimeerr-advanced} |
| 108 | + |
| 109 | +_These are important topics that are not expected to be covered but provide |
| 110 | +guidance where one can continue to investigate this topic in more depth._ |
| 111 | + |
| 112 | +* ABI incompatibilities can have impact debugging experience where even observability tools, such as, debuggers, cannot correctly show the state of the program. |
| 113 | +* Debugging in embedded environments. |
0 commit comments