* another conditional breakpoint question
@ 2002-09-20 13:13 Peter Jay Salzman
2002-09-20 15:04 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Peter Jay Salzman @ 2002-09-20 13:13 UTC (permalink / raw)
To: Gdb Mailing List
in the program:
#include <math.h>
int main(void)
{
double i = 0.0;
double j = cos(i);
return 0;
}
i set a breakpoint which should never be reached:
p@satan% gdb mymath
(gdb) break main if cos(0.0) > 1000.0
Breakpoint 1 at 0x8048426: file mymath.c, line 5.
(gdb) run
Breakpoint 1, main () at mymath.c:5
5 double i = 0.0;
considering that cosine should be greater than 1 for a real variable,
this is quite strange!
i don't know if this is related, but i notice that cos(0) doesn't have a
value of 1.0. not even close:
(gdb) p cos(0)
$3 = 14368
but just in case gdb doesn't know that cos() returns a double, i also
tried:
(gdb) p/f cos(0.0)
$1 = 2.00890148e-41
neither of these are even close to being right.
can someone tell me why gdb is reaching that breakpoint which should
never be reaced? and is there any way of getting gdb to tell me that
cos(0) is supposed to be equal to 1? :*)
thanks!
pete
--
Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: another conditional breakpoint question
2002-09-20 13:13 another conditional breakpoint question Peter Jay Salzman
@ 2002-09-20 15:04 ` Daniel Jacobowitz
2002-09-20 15:36 ` Peter Jay Salzman
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2002-09-20 15:04 UTC (permalink / raw)
To: Peter Jay Salzman; +Cc: Gdb Mailing List
On Fri, Sep 20, 2002 at 01:13:04PM -0700, Peter Jay Salzman wrote:
> in the program:
>
> #include <math.h>
> int main(void)
> {
> double i = 0.0;
> double j = cos(i);
> return 0;
> }
>
> i set a breakpoint which should never be reached:
>
> p@satan% gdb mymath
> (gdb) break main if cos(0.0) > 1000.0
> Breakpoint 1 at 0x8048426: file mymath.c, line 5.
>
> (gdb) run
> Breakpoint 1, main () at mymath.c:5
> 5 double i = 0.0;
>
> considering that cosine should be greater than 1 for a real variable,
> this is quite strange!
>
>
> i don't know if this is related, but i notice that cos(0) doesn't have a
> value of 1.0. not even close:
>
> (gdb) p cos(0)
> $3 = 14368
>
> but just in case gdb doesn't know that cos() returns a double, i also
> tried:
>
> (gdb) p/f cos(0.0)
> $1 = 2.00890148e-41
>
> neither of these are even close to being right.
>
>
> can someone tell me why gdb is reaching that breakpoint which should
> never be reaced? and is there any way of getting gdb to tell me that
> cos(0) is supposed to be equal to 1? :*)
You don't have debug information in your libraries. Try:
(gdb) ptype cos
to see what I mean. You need debugging info if you want that to wokr.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: another conditional breakpoint question
2002-09-20 15:04 ` Daniel Jacobowitz
@ 2002-09-20 15:36 ` Peter Jay Salzman
2002-09-20 16:16 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Peter Jay Salzman @ 2002-09-20 15:36 UTC (permalink / raw)
To: Gdb Mailing List
begin Daniel Jacobowitz <drow@mvista.com>
> On Fri, Sep 20, 2002 at 01:13:04PM -0700, Peter Jay Salzman wrote:
> > in the program:
> >
> > #include <math.h>
> > int main(void)
> > {
> > double i = 0.0;
> > double j = cos(i);
> > return 0;
> > }
> >
> > i set a breakpoint which should never be reached:
> >
> > p@satan% gdb mymath
> > (gdb) break main if cos(0.0) > 1000.0
> > Breakpoint 1 at 0x8048426: file mymath.c, line 5.
> >
> > (gdb) run
> > Breakpoint 1, main () at mymath.c:5
> > 5 double i = 0.0;
> >
> > considering that cosine should be greater than 1 for a real variable,
> > this is quite strange!
> >
> >
> > i don't know if this is related, but i notice that cos(0) doesn't have a
> > value of 1.0. not even close:
> >
> > (gdb) p cos(0)
> > $3 = 14368
> >
> > but just in case gdb doesn't know that cos() returns a double, i also
> > tried:
> >
> > (gdb) p/f cos(0.0)
> > $1 = 2.00890148e-41
> >
> > neither of these are even close to being right.
> >
> >
> > can someone tell me why gdb is reaching that breakpoint which should
> > never be reaced? and is there any way of getting gdb to tell me that
> > cos(0) is supposed to be equal to 1? :*)
>
> You don't have debug information in your libraries. Try:
>
> (gdb) ptype cos
>
> to see what I mean. You need debugging info if you want that to wokr.
hi daniel,
i see what you mean. but then i'm confused why strlen works.
18 int main(void)
19 {
20 char *string = "GNU/Linux";
21 char revstring[255];
22
23 reverse(string, revstring);
24 printf("%s\n", revstring);
25
26 return 0;
27 }
(gdb) break 21 if strlen(string) == 9
Breakpoint 3 at 0x8048440: file string_reverse.c, line 21.
(gdb) run
Starting program: /home/p/writing/ddd/src/string_reverse
Breakpoint 3, main () at string_reverse.c:23
23 reverse(string, revstring);
i have libc6 and libc6-dev installed on my system, but not libc6-dbg.
other string stuff works to, like:
break main if ! strcmp("hello", "hello")
considering that i don't have the dbg versions of either libm or libc6,
do you have any idea why the string functions would work in the
conditionals but not the math functions?
thanks!
pete
--
Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: another conditional breakpoint question
2002-09-20 15:36 ` Peter Jay Salzman
@ 2002-09-20 16:16 ` Daniel Jacobowitz
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2002-09-20 16:16 UTC (permalink / raw)
To: Peter Jay Salzman; +Cc: Gdb Mailing List
On Fri, Sep 20, 2002 at 03:36:06PM -0700, Peter Jay Salzman wrote:
> begin Daniel Jacobowitz <drow@mvista.com>
> > On Fri, Sep 20, 2002 at 01:13:04PM -0700, Peter Jay Salzman wrote:
> > > in the program:
> > >
> > > #include <math.h>
> > > int main(void)
> > > {
> > > double i = 0.0;
> > > double j = cos(i);
> > > return 0;
> > > }
> > >
> > > i set a breakpoint which should never be reached:
> > >
> > > p@satan% gdb mymath
> > > (gdb) break main if cos(0.0) > 1000.0
> > > Breakpoint 1 at 0x8048426: file mymath.c, line 5.
> > >
> > > (gdb) run
> > > Breakpoint 1, main () at mymath.c:5
> > > 5 double i = 0.0;
> > >
> > > considering that cosine should be greater than 1 for a real variable,
> > > this is quite strange!
> > >
> > >
> > > i don't know if this is related, but i notice that cos(0) doesn't have a
> > > value of 1.0. not even close:
> > >
> > > (gdb) p cos(0)
> > > $3 = 14368
> > >
> > > but just in case gdb doesn't know that cos() returns a double, i also
> > > tried:
> > >
> > > (gdb) p/f cos(0.0)
> > > $1 = 2.00890148e-41
> > >
> > > neither of these are even close to being right.
> > >
> > >
> > > can someone tell me why gdb is reaching that breakpoint which should
> > > never be reaced? and is there any way of getting gdb to tell me that
> > > cos(0) is supposed to be equal to 1? :*)
> >
> > You don't have debug information in your libraries. Try:
> >
> > (gdb) ptype cos
> >
> > to see what I mean. You need debugging info if you want that to wokr.
>
> hi daniel,
>
> i see what you mean. but then i'm confused why strlen works.
>
> 18 int main(void)
> 19 {
> 20 char *string = "GNU/Linux";
> 21 char revstring[255];
> 22
> 23 reverse(string, revstring);
> 24 printf("%s\n", revstring);
> 25
> 26 return 0;
> 27 }
>
> (gdb) break 21 if strlen(string) == 9
> Breakpoint 3 at 0x8048440: file string_reverse.c, line 21.
It returns an int. That's what GDB assumes when it has no better
information. You get lucky.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-09-20 23:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-20 13:13 another conditional breakpoint question Peter Jay Salzman
2002-09-20 15:04 ` Daniel Jacobowitz
2002-09-20 15:36 ` Peter Jay Salzman
2002-09-20 16:16 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox