What make the directive run twice?

Jason Luo jasonl@turbolinux.com.cn
Thu Jun 3 07:10:00 GMT 2004


Hi all,

I use gdb 6.1 to debug Grub 0.94.When I debug the function check_device 
in lib/device.c,I found that the fopen directive was run twice.

[root@jason build]# gdb grub/grub
.........
(gdb) b device.c:617
Breakpoint 1 at 0x805dc29: file ../../lib/device.c, line 617.
(gdb) r
Starting program: /home/jason/sources/grub-0.94/build/grub/grub
Probing devices to guess BIOS drives. This may take a long time.

Breakpoint 1, init_device_map (map=0x806609c, map_file=0xbfffd350 "", 
floppy_disks=1)
     at ../../lib/device.c:617
617           get_ide_disk_name (name, i);
(gdb) n
618           if (check_device (name))
(gdb) s                             //here,I step in check_device
check_device (device=0xbfffd350 "/dev/hda") at ../../lib/device.c:321
321       if (*device == 0)
(gdb) p device
$1 = 0xbfffd350 "/dev/hda"
(gdb) n
324       fp = fopen (device, "r");
(gdb)
325       if (! fp)
(gdb)
346           return 0;             //return from here,but...
(gdb)
324       fp = fopen (device, "r");   //come to here!!!
(gdb) p device
$2 = 0x8073860 "\210$?"       //the parameter device was changed!!!!
(gdb) n
346           return 0;       //return from here,but
(gdb)
353       if (ioctl (fileno (fp), CDROM_GET_CAPABILITY, 0) >= 0)
(gdb)


When this section in gdb,the process is not correct and the device 
parameter of check_device function was changed.

what cause it?How can I do it?

My env is  gcc 3.3.1,glibc 2.3.2,Intel(R) Pentium(R) 4 CPU 2.60GHz with HT.

Jason



More information about the Gdb mailing list