BSD 3 development
[unix-history] / usr / doc / sdb / app1
CommitLineData
5ce2aa3e
HK
1% cat testdiv2.c
2main() {
3 int i;
4 i = div2(-1);
5 printf("-1/2 = %d\n", i);
6}
7div2(i) {
8 int j;
9 j = i>>1;
10 return(j);
11}
12
13% cc -g testdiv2.c
14
15% a.out
16-1/2 = -1
17
18% sdb
19No core image # Warning message from sdb
20*/^div2 # Search for procedure "div2"
216: div2(i) { # It starts at line 6
22*z # Print the next few lines
236: div2(i) {
247: int j;
258: j = i>>1;
269: return(j);
2710: }
28*div2:b # Place a breakpoint at beginning of div2
29div2:8 b # Sdb echoes proc name and line number
30*r # Run the procedure
31Breakpoint at # Execution stops just before line 8
32div2:8: j = i>>1;
33*t # Print trace of subroutine calls
34div2(-1) [testdiv2.c:8]
35main(1,2147483380,2147483388) [testdiv2.c:3]
36*i/ # Print i
37-1
38*s # Single step
39div2:9: return(j); # Execution stops just before line 9
40*j/ # Print j
41-1
42*8d # Delete the breakpoint
43*div2(1)/ # Try running div2 with different args
440
45*div2(-2)/
46-1
47*div2(-3)/
48-2
49*q # Exit sdb