PDA

View Full Version : Error in issue 23



Fatboy Snarky
April 1st, 2009, 01:16 AM
Hi,


in issue 23 there is an error in the "program in C" how-to
(part 7) on pages 12 and 13:

In the righthand code boxes, the screen output of the "gdb" debugger is shown in truncated form.

The error is that the corresponding text refers to parts of the screen output that has been actually cut away.

E.g.: page 12, first and second columns say:
"[...] gdb told us the application was terminated due to a segmentation violation. We entered where, and gdb responded with a backtrace [...]".

But those lines are not visible on the right side of the page. (While the whole license blob of gdb is shown unabriged).

HTH,
Ulrich

amo-ej1
April 4th, 2009, 11:49 AM
Hi,

Well you're absolutely correct, the text seems to have gotten lost in editing/reviewing. But it's often rather tricky, when I have to submit these large blobs of text/listings I know it'll be a major pain in the *ss to get things formatted properly.

Below you'll able to find the 'missing text':




edb@lapedb:~/fullcircle/c-7$ gdb ifstat core
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/tls/i686/cmov/libc.so.6...done.
Loaded symbols for /lib/tls/i686/cmov/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./ifstat b'.
Program terminated with signal 11, Segmentation fault.
[New process 8660]
#0 0xb7f7d6c7 in rawmemchr () from /lib/tls/i686/cmov/libc.so.6
(gdb) where
#0 0xb7f7d6c7 in rawmemchr () from /lib/tls/i686/cmov/libc.so.6
#1 0xb7f72d4b in ?? () from /lib/tls/i686/cmov/libc.so.6
#2 0xb7f660d3 in vsscanf () from /lib/tls/i686/cmov/libc.so.6
#3 0xb7f6072b in sscanf () from /lib/tls/i686/cmov/libc.so.6
#4 0x08048670 in parseDevFile (iface=0xbfd9a783 "b", bRx=0xbfd99ae0, pRx=0xbfd99ad0, bTx=0xbfd99ad8, pTx=0xbfd99ac8) at ifstat.c:25
#5 0x0804875a in dumpInterfaceUsage (iface=0xbfd9a783 "b") at ifstat.c:40
#6 0x08048999 in main (argc=2, argv=0xbfd99bc4) at ifstat.c:65
(gdb) up
#1 0xb7f72d4b in ?? () from /lib/tls/i686/cmov/libc.so.6
(gdb) up
#2 0xb7f660d3 in vsscanf () from /lib/tls/i686/cmov/libc.so.6
(gdb) up
#3 0xb7f6072b in sscanf () from /lib/tls/i686/cmov/libc.so.6
(gdb) up
#4 0x08048670 in parseDevFile (iface=0xbfd9a783 "b", bRx=0xbfd99ae0, pRx=0xbfd99ad0, bTx=0xbfd99ad8, pTx=0xbfd99ac8) at ifstat.c:25
25 sscanf(strstr(line,":")+1,"%llu%llu%*u%*u%*u%*u%*u%*u%llu%llu",
(gdb) print line
$1 = 0x9d8c170 " face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed\n"




edb@lapedb:~/fullcircle/c-7$ gdb ifstat
(gdb) break parseDevFile
Breakpoint 1 at 0x80485da: file ifstat.c, line 11.
(gdb) run bla
Starting program: /home/edb/fullcircle/c-7/ifstat bla
Breakpoint 1, parseDevFile (iface=0xbf96175d "bla", bRx=0xbf961290, pRx=0xbf961280, bTx=0xbf961288, pTx=0xbf961278) at ifstat.c:11
11 FILE * fp = NULL;
(gdb) step
12 char * line = NULL;
(gdb) step
13 unsigned int len = 0;
(gdb) step
15 fp = fopen("/proc/net/dev", "r");
(gdb) step
16 if(fp==NULL)
(gdb) print fp
$1 = (FILE *) 0x9e20008
(gdb) step
21 while(getline(&line,&len,fp)!= -1)
(gdb) display line
1: line = 0x0
(gdb) step
23 if(strstr(line,iface)!=NULL)
1: line = 0x9e20170 "Inter-| Receive", ' ' <repeats 48 times>, "| Transmit\n"
(gdb) step
21 while(getline(&line,&len,fp)!= -1)
1: line = 0x9e20170 "Inter-| Receive", ' ' <repeats 48 times>, "| Transmit\n"
(gdb) step
23 if(strstr(line,iface)!=NULL)
1: line = 0x9e20170 " face |bytes packets errs drop fifo frame compressed multicast\n"
(gdb) step
21 while(getline(&line,&len,fp)!= -1)
1: line = 0x9e20170 " face |bytes packets errs drop fifo frame compressed multicast\n"
(gdb) step
23 if(strstr(line,iface)!=NULL)
1: line = 0x9e20170 " wlan0:97140829 188484 0 0 0 0 0 0\n"
(gdb) step
21 while(getline(&line,&len,fp)!= -1)
1: line = 0x9e20170 " wlan0:97140829 188484 0 0 0 0 0 0\n"
(gdb) step
29 fclose(fp);
(gdb) cont
Continuing.
Breakpoint 1, parseDevFile (iface=0xbf96175d "bla", bRx=0xbf961270, pRx=0xbf961260, bTx=0xbf961268, pTx=0xbf961258) at ifstat.c:11
11 FILE * fp = NULL;

dark_religion
November 13th, 2009, 09:54 PM
Interesting situation.