I have C code which uses math functions for which I need to include math.h
(my box is i686-pc-linux-gnu). In ddd, if I type "print exp(-1.23)" into the
gdb console, i expect (and desire) to see the value 0.292293... printed out.
Instead, i see:
(gdb) print exp(-1.23)
$28 = 1
How does one make ddd (gdb) evaluate and print the value of expressions
(like exp(-1.23)) involving math functions? |
Request for Question Clarification by
maniac-ga
on
16 Jul 2004 17:39 PDT
Hello Ignorant-ga,
Odd. When I used a sample program that had #include <math.h>, set a
breakpoint in the main program, and got the following results:
(gdb) print exp(-1.23)
Unable to call function at 0x90041320: no return type information available.
To call this function anyway, you can cast the return type explicitly
(e.g. 'print (float) fabs (3.0)')
(gdb)
No source file named 0x90041320.
(gdb) print (float) exp(-1.23)
$1 = 0.292292565
(gdb)
So, on my system - gdb knows where exp is defined but does not have
sufficient information for the function call. When you use the
suggested syntax - it does work OK.
In case its a version problem, on my system, I have
gcc 3.3
gdb 5.3
ddd 3.3.7
Please try the syntax above - if it works, indicate so I can prepare a
proper answer. If not, let me know what OS, gcc, and gdb versions you
are using so I can suggest a better answer.
--Maniac
|
Clarification of Question by
ignorant-ga
on
17 Jul 2004 07:56 PDT
Typecasting does not help...
gcc 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
gdb GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
ddd GNU DDD 3.3.8 (i686-pc-linux-gnu)
|
Request for Question Clarification by
maniac-ga
on
17 Jul 2004 18:17 PDT
Grr. I was afraid of that. Let me see if I can find a similarly
configured system to do some testing and make some suggestions.
--Maniac
|
Request for Question Clarification by
maniac-ga
on
19 Jul 2004 17:55 PDT
Hello Ignorant-ga,
I checked on a couple linux systems:
Fedora Core 2
Red Hat Linux 7.3
and reproduced the symptom on both. I also checked the gdb bug list -
nothing there that looked relevant. I have a query in to Red Hat to
see if they are aware of the problem / can provide an updated gdb. I
will get back if I hear anything.
--Maniac
|