@@ -173,7 +173,7 @@ Why do you think it's broken?
173
173
What fixes did you try?
174
174
175
175
(This may seem foolish, but this technique once revealed to me that I had been debugging code
176
- for an hour under the misapprehension that 9 was a prime number.
176
+ for an hour under the misapprehension that 9 was a prime number.[ ^ statistically ]
177
177
You'd be amazed at the things you don't realize until you think about how to explain something
178
178
to someone else.)
179
179
@@ -293,7 +293,7 @@ For example, if your code segfaults, it'll print something like
293
293
294
294
~~~
295
295
Program received signal SIGSEGV, Segmentation fault.
296
- 0x0000555555554923 in pretty_print (array=...) at segfault.cpp:14
296
+ 0x555555554923 in pretty_print (array=...) at segfault.cpp:14
297
297
14 cout << array.elements[i] << ", ";
298
298
~~~
299
299
@@ -317,8 +317,8 @@ you can use the `backtrace` (or `bt` for short) command to ask `gdb` where you c
317
317
318
318
~~~
319
319
(gdb) bt
320
- #0 0x0000555555554923 in pretty_print (array=...) at segfault.cpp:14
321
- #1 0x00005555555549b3 in main () at segfault.cpp:24
320
+ #0 0x555555554923 in pretty_print (array=...) at segfault.cpp:14
321
+ #1 0x5555555549b3 in main () at segfault.cpp:24
322
322
~~~
323
323
324
324
The backtrace shows you the function stack: starting from ` main() ` ,
@@ -372,9 +372,10 @@ the next (`main`) is numbered `1`, and so on.
372
372
` up ` increments the number of the selected stack frame; ` down ` decrements it.
373
373
374
374
So, for example, to move to ` main ` 's stack frame, we'd do:
375
+
375
376
~~~
376
377
(gdb) up
377
- #1 0x00005555555549b3 in main () at segfault.cpp:24
378
+ #1 0x5555555549b3 in main () at segfault.cpp:24
378
379
24 pretty_print(stuff);
379
380
~~~
380
381
@@ -469,15 +470,15 @@ Breakpoint 2 at 0x555555554b05: file guess.cpp, line 17.
469
470
(gdb) break 19
470
471
Breakpoint 3 at 0x555555554ba0: file guess.cpp, line 19.
471
472
(gdb) info breakpoints
472
- Num Type Disp Enb Address What
473
- 1 breakpoint keep y 0x0000555555554af6 at guess.cpp:15
474
- 2 breakpoint keep y 0x0000555555554b05 at guess.cpp:17
475
- 3 breakpoint keep y 0x0000555555554ba0 at guess.cpp:19
473
+ Num Type Disp Enb Address What
474
+ 1 breakpoint keep y 0x555555554af6 at guess.cpp:15
475
+ 2 breakpoint keep y 0x555555554b05 at guess.cpp:17
476
+ 3 breakpoint keep y 0x555555554ba0 at guess.cpp:19
476
477
(gdb) delete 2
477
478
(gdb) info breakpoints
478
- Num Type Disp Enb Address What
479
- 1 breakpoint keep y 0x0000555555554af6 at guess.cpp:15
480
- 3 breakpoint keep y 0x0000555555554ba0 at guess.cpp:19
479
+ Num Type Disp Enb Address What
480
+ 1 breakpoint keep y 0x555555554af6 at guess.cpp:15
481
+ 3 breakpoint keep y 0x555555554ba0 at guess.cpp:19
481
482
~~~
482
483
483
484
#### Stepping through the code
@@ -639,7 +640,7 @@ Name: `______________________________`
639
640
2. How would you set a breakpoint for line 17 of file `my_funcs.cpp`?
640
641
\vspace{10em}
641
642
642
- 3. Consult `help list`. How would you list the source code of the `encabulate_beziers` function ?
643
+ 3. Consult `help list`. How would you list the source code of a function named `encabulate_beziers`?
643
644
\vspace{10em}
644
645
645
646
4. What is the difference between `break` and `advance`?
@@ -701,3 +702,4 @@ Name: `______________________________`
701
702
[^dont]: Don't actually do this, though.
702
703
We're just demonstrating how you'd pass command line arguments.
703
704
[^picture]: Well, a picture of her. The publisher wouldn't let us include a live chicken tucked between the pages of the book.
705
+ [^statistically]: In my defense, odd numbers between 2 and 10 have a 75% chance of being prime, so I was statistically correct!
0 commit comments