Question: different GDB behavors with UCLIBC_HAS_OBSTACK enabled and disabled

Sheng Yong shengyong1 at huawei.com
Thu May 28 03:48:19 UTC 2015


Hi, folks

My test environment is GCC (4.7.1), GDB (7.6) and uclibc (0.9.33.2 commit ff22cca4).

The testcase is:

	$ cat long_long_simple.c
	#include <stdio.h>

	int main()
	{
		long long val = 01234567123456701234567LL; /* 21+ octal digits */
		printf("%.17g\n", val);
		return 0;
	}

Debug the program with UCLIBC_HAS_OBSTACK *disabled*:

	sh-4.2# ./long_long_simple
	-5.9822653797615731e-120

	sh-4.2# gdb ./long_long_simple
	GNU gdb (GDB) 7.6
	[...]
	(gdb) b 6
	Breakpoint 1 at 0x84f0: file long_long_simple.c, line 6.
	(gdb) r
	Starting program: /tmp/long_long_simple

	Breakpoint 1, main () at long_long_simple.c:6
	6	long_long_simple.c: No such file or directory.
	(gdb) p val
	$1 = -6399925985474168457
	(gdb) p/o val
	$2 = 01234567123456701234567
	(gdb) p/f val
	$3 = -5.9822653797615723e-120

Debug the program with UCLIBC_HAS_OBSTACK *enabled*:

	sh-4.2# ./long_long_simple
	-5.9822653797615731e-120

	sh-4.2# gdb long_long_simple
	GNU gdb (GDB) 7.6
	[...]
	(gdb) b 6
	Breakpoint 1 at 0x84f0: file long_long_simple.c, line 6.
	(gdb) r
	Starting program: /tmp/long_long_simple

	Breakpoint 1, main () at long_long_simple.c:6
	6	long_long_simple.c: No such file or directory.
	(gdb) p val
	$1 = -6399925985474168457
	(gdb) p/o val
	$2 = 01234567123456701234567
	(gdb) p/f val
	$3 = -5.9822653797615731e-120

>From the value of `$2', we could see that GDB get the correct value of `val'.
But if we format the value as `p/f', the two values of `$3' are not the same:
$3 = -5.98226537976157*23e*-120    UCLIBC_HAS_OBSTACK disabled, this is the expected value
$3 = -5.98226537976157*31e*-120    UCLIBC_HAS_OBSTACK enabled, this value is not correct

I have no idea if the problem has anything to do with http://lists.uclibc.org/pipermail/uclibc/2015-May/048932.html
Did anyone ever hit this case? Any suggestion is appreciated.

Thanks,
Sheng



More information about the uClibc mailing list