dspinellis / dspinellis/effective-debugging

Page 94, Listing 4.1

Open
#13 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
53
Forks
19
PR merge metrics
No merged PRs in 30d

Description

The listing should be read as follows, correcting the order of the defined breakpoints.

```
# Define a counter variable to keep track of locks
set $nlock = 0

# Stop the execution with a backtrace on nested locks
break lock if $nlock > 0
commands
silent
echo Nested lock\n
# Display the stack trace
backtrace
# Stop the program's execution
break
end

# Stop the execution with a backtrace on duplicate unlocks
break unlock if $nlock <= 0
commands
silent
echo Duplicate unlock\n
backtrace
break
end

# When the lock routine is called, increase the counter
# Define a new breakpoint
break lock
# Commands to execute when the lock routine is called
commands
silent
# Increment counter variable
set $nlock = $nlock + 1
# Continue the program's execution
continue
end

# When the unlock routine is called, decrease the counter
break unlock
commands
silent
set $nlock = $nlock - 1
continue
end
```

Spotted and corrected by Naohiro Ooiwa-san.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.