Use these 5 strategies to give students useful debugging strategies that will help them fix Segmentation Faults.

  • Strategy 1:
    • Use Backtrack.
      • GDB is a great tool, but students are often overwhelmed by all the hex.
        • Students need time and practice to become comfortable with GDB.
      • Students need to understand where in the code the segmentation fault occurs.
      • Segmentation fault is a symptom of a memory problem, not necessarily the actual problem!
        • It’s very important that students recognize this.
  • Strategy 2:
    • Have Students answer the following questions:
      • Where do things work?
      • Where do things break?
    • Just getting students to think about these questions explicitly can help them get unstuck.
  • Strategy 3:
    • Use breakpoints to find where the code failed.
      • Start with a good call.
        • The beginning of the function that failed is always an option.
      • Next, step line by line through the function to isolate where the problem is.
      • Have students examine the line of code where the code failed very closely.
  • Strategy 4:
    • Ask students, "What should be going on?"
      • Have them start from a call they know is good.
      • Then, pair this information with the type of error being experienced.
      • This can help facilitate critical thinking to uncover what’s really happening.
  • Strategy 5:
    • Draw diagrams if students can identify the line of code containing the error but cannot understand how to debug it.
      • Let the scratch paper tell students what should be going on by tracing through what the program is doing.
        • Notably, this is in contrast with what the program is supposed to do.
          • Students tend to think about what the program is supposed to do which can be a huge impediment for debugging.
        • Make sure students always keep scratch paper on hand.
      • Sometimes students are not familiar enough with the content to understand how to proceed, which can be the best time to use this technique.

More about this tip

External Source

Interview with Walt Schilling