[opensuse-programming] lib failure?
Hello, I was facing a problem with a functio I wrote, checking if a file exists withing the fs. When I was debuggin that , I set 2 breakpoints, the first to the function file_exists and the second to the function call of file_exists inside the program. I got the following output **************************** gdb ************************************ Breakpoint 2, main (argc=1, argv=0xbffff1c4) at ddnscli.c:712 712 if(file_exists(lockfile)) (gdb) s Breakpoint 1, file_exists (fname=0xbffff110 "disabled") at ddnscli.c:689 689 if( (rval = stat( fname, &attribut)) == -1) (gdb) s __stat (file=0xbffff070 "\200", buf=0xbffff070) at stat.c:51 51 stat.c: Datei oder Verzeichnis nicht gefunden. in stat.c (gdb) bt full #0 __stat (file=0xbffff070 "\200", buf=0xbffff070) at stat.c:51 No locals. #1 0x0804a56b in file_exists (fname=0xbffff110 "disabled") at ddnscli.c:689 attribut = {st_dev = 128, __pad1 = 34760, st_ino = 7, st_mode = 53, st_nlink = 1075277812, st_uid = 1075283840, st_gid = 134522768, st_rdev = 4615200421588234412, __pad2 = 34688, st_size = 40, st_blksize = 1075277812, st_blocks = 1073835200, st_atime = 134522768, st_atimensec = 3221221564, st_mtime = 1074560382, st_mtimensec = 40, st_ctime = 1075277812, st_ctimensec = 3221221592, __unused4 = 1074559989, __unused5 = 40} rval = 1075277812 ************************************************************************************* __stat (file=0xbffff070 "\200", buf=0xbffff070) at stat.c:51 both arguments of stat hold the same address. file should be AFAIK fname=0xbffff110. I isolated the function to a test_program and it works fine there. Any ideas? Regards, Oliver -- Leben ist mehr als ... <http://www.nak-nrw.de/index.php?id=71> --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
On Mon, Nov 27, 2006 at 03:57:43PM +0100, Oliver Block wrote:
Hello,
I was facing a problem with a functio I wrote, checking if a file exists withing the fs. When I was debuggin that , I set 2 breakpoints, the first to the function file_exists and the second to the function call of file_exists inside the program. I got the following output
**************************** gdb ************************************ Breakpoint 2, main (argc=1, argv=0xbffff1c4) at ddnscli.c:712 712 if(file_exists(lockfile)) (gdb) s
Breakpoint 1, file_exists (fname=0xbffff110 "disabled") at ddnscli.c:689 689 if( (rval = stat( fname, &attribut)) == -1) (gdb) s __stat (file=0xbffff070 "\200", buf=0xbffff070) at stat.c:51 51 stat.c: Datei oder Verzeichnis nicht gefunden. in stat.c (gdb) bt full #0 __stat (file=0xbffff070 "\200", buf=0xbffff070) at stat.c:51 No locals. #1 0x0804a56b in file_exists (fname=0xbffff110 "disabled") at ddnscli.c:689 attribut = {st_dev = 128, __pad1 = 34760, st_ino = 7, st_mode = 53, st_nlink = 1075277812, st_uid = 1075283840, st_gid = 134522768, st_rdev = 4615200421588234412, __pad2 = 34688, st_size = 40, st_blksize = 1075277812, st_blocks = 1073835200, st_atime = 134522768, st_atimensec = 3221221564, st_mtime = 1074560382, st_mtimensec = 40, st_ctime = 1075277812, st_ctimensec = 3221221592, __unused4 = 1074559989, __unused5 = 40} rval = 1075277812 *************************************************************************************
__stat (file=0xbffff070 "\200", buf=0xbffff070) at stat.c:51
both arguments of stat hold the same address. file should be AFAIK fname=0xbffff110.
I isolated the function to a test_program and it works fine there.
Any ideas?
Showing us the actual source of the function would perhaps help. Ciao, Marcus --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
Hi Marcus, this is the function code ************************** function code ********************* int file_exists(const char *fname) { struct stat attribut; if( (stat(fname, &attribut)) == -1) { if(errno == ENOENT) return false; else printf("stat() Fehler: %d\n", errno); } else if( S_ISREG(attribut.st_mode)) return true; return false; } *********************************************************** As I could find out so far, it's likely that this is problem of gdb. strace states that stat gets the correct argument. Regards, Oliver Am Montag, 27. November 2006 16:08 schrieben Sie:
On Mon, Nov 27, 2006 at 03:57:43PM +0100, Oliver Block wrote:
Hello,
I was facing a problem with a functio I wrote, checking if a file exists withing the fs. When I was debuggin that , I set 2 breakpoints, the first to the function file_exists and the second to the function call of file_exists inside the program. I got the following output
**************************** gdb ************************************ Breakpoint 2, main (argc=1, argv=0xbffff1c4) at ddnscli.c:712 712 if(file_exists(lockfile)) (gdb) s
Breakpoint 1, file_exists (fname=0xbffff110 "disabled") at ddnscli.c:689 689 if( (rval = stat( fname, &attribut)) == -1) (gdb) s __stat (file=0xbffff070 "\200", buf=0xbffff070) at stat.c:51 51 stat.c: Datei oder Verzeichnis nicht gefunden. in stat.c (gdb) bt full #0 __stat (file=0xbffff070 "\200", buf=0xbffff070) at stat.c:51 No locals. #1 0x0804a56b in file_exists (fname=0xbffff110 "disabled") at ddnscli.c:689 attribut = {st_dev = 128, __pad1 = 34760, st_ino = 7, st_mode = 53, st_nlink = 1075277812, st_uid = 1075283840, st_gid = 134522768, st_rdev = 4615200421588234412, __pad2 = 34688, st_size = 40, st_blksize = 1075277812, st_blocks = 1073835200, st_atime = 134522768, st_atimensec = 3221221564, st_mtime = 1074560382, st_mtimensec = 40, st_ctime = 1075277812, st_ctimensec = 3221221592, __unused4 = 1074559989, __unused5 = 40} rval = 1075277812 ************************************************************************* ************
__stat (file=0xbffff070 "\200", buf=0xbffff070) at stat.c:51
both arguments of stat hold the same address. file should be AFAIK fname=0xbffff110.
I isolated the function to a test_program and it works fine there.
Any ideas?
Showing us the actual source of the function would perhaps help.
Ciao, Marcus
-- Leben ist mehr als ... <http://www.nak-nrw.de/index.php?id=71> --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
On Mon, Nov 27, 2006 at 06:07:32PM +0100, Oliver Block wrote:
Hi Marcus,
this is the function code
************************** function code *********************
int file_exists(const char *fname) { struct stat attribut;
if( (stat(fname, &attribut)) == -1) { if(errno == ENOENT) return false; else printf("stat() Fehler: %d\n", errno); } else if( S_ISREG(attribut.st_mode)) return true;
return false; } ***********************************************************
As I could find out so far, it's likely that this is problem of gdb. strace states that stat gets the correct argument.
I have to agree. The code itself looks fine. Ciao, Marcus --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-programming+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-programming+help@opensuse.org
participants (2)
-
Marcus Meissner
-
Oliver Block