* question about conditional breaking
@ 2002-09-20 0:36 Peter Jay Salzman
2002-09-20 6:46 ` Daniel Jacobowitz
2002-09-20 8:46 ` Kevin Buettner
0 siblings, 2 replies; 3+ messages in thread
From: Peter Jay Salzman @ 2002-09-20 0:36 UTC (permalink / raw)
To: Gdb Mailing List
dear gdb mailing list,
the gdb user's manual doesn't have a lot to say about conditional
breaking, but i think i'm beginning to understand it more thoroughly.
first, we know that the boolean expressions you'd expect to be able to
use, work as advertised.
break 1 if x > 0
break 2 if y <= x
parenthesis seem to be purely optional.
break 3 if (! x >= -1)
but there seems to be more to the story. you can use functions too.
here's a test program:
#include <math.h>
int main(void)
{
double l = cos(i);
double m = y0(i);
return 0;
}
where y0 is a bessel function of the 2nd kind (a von neumann function)
of the zeroth order.
it seems like you can use functions, like math library functions. but
with a privisio:
(gdb) break main if cos(3) == 0
Breakpoint 1 at 0x8048456: file math.c, line 5.
(gdb) break main if sin(3) == 0
No symbol "sin" in current context.
(gdb) break main if exp(3) == 0
No symbol "exp" in current context.
(gdb) break main if y0(3) == 0
Note: breakpoint 1 also set at pc 0x8048456.
Breakpoint 2 at 0x8048456: file math.c, line 5.
(gdb) break main if y1(3) == 0
No symbol "y1" in current context.
so it appears that here's the rule:
you're allowed to use any function, even library functions, provided that:
1. the library is linked to your application
2. you actually _use_ the function somewhere in your code.
to be honest, i'm not the least surprised by condition 1, but i'm
shocked by condition 2.
does anyone have anything to add to this? am i on the right track here?
pete
--
Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: question about conditional breaking
2002-09-20 0:36 question about conditional breaking Peter Jay Salzman
@ 2002-09-20 6:46 ` Daniel Jacobowitz
2002-09-20 8:46 ` Kevin Buettner
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2002-09-20 6:46 UTC (permalink / raw)
To: Gdb Mailing List
On Fri, Sep 20, 2002 at 12:36:48AM -0700, Peter Jay Salzman wrote:
> dear gdb mailing list,
>
> the gdb user's manual doesn't have a lot to say about conditional
> breaking, but i think i'm beginning to understand it more thoroughly.
>
> first, we know that the boolean expressions you'd expect to be able to
> use, work as advertised.
>
> break 1 if x > 0
> break 2 if y <= x
>
> parenthesis seem to be purely optional.
>
> break 3 if (! x >= -1)
>
>
> but there seems to be more to the story. you can use functions too.
> here's a test program:
>
> #include <math.h>
>
> int main(void)
> {
> double l = cos(i);
> double m = y0(i);
>
> return 0;
> }
>
>
> where y0 is a bessel function of the 2nd kind (a von neumann function)
> of the zeroth order.
>
> it seems like you can use functions, like math library functions. but
> with a privisio:
>
> (gdb) break main if cos(3) == 0
> Breakpoint 1 at 0x8048456: file math.c, line 5.
>
> (gdb) break main if sin(3) == 0
> No symbol "sin" in current context.
>
> (gdb) break main if exp(3) == 0
> No symbol "exp" in current context.
>
> (gdb) break main if y0(3) == 0
> Note: breakpoint 1 also set at pc 0x8048456.
> Breakpoint 2 at 0x8048456: file math.c, line 5.
>
> (gdb) break main if y1(3) == 0
> No symbol "y1" in current context.
>
>
> so it appears that here's the rule:
>
> you're allowed to use any function, even library functions, provided that:
>
> 1. the library is linked to your application
> 2. you actually _use_ the function somewhere in your code.
>
> to be honest, i'm not the least surprised by condition 1, but i'm
> shocked by condition 2.
You can use any C expression that GDB can evaluate to a value; see the
'print' command. (2) should not be necessary if you have shared
libraries; but if you don't, then the function is likely to not be
present in the application unless you used it. GDB can't call
functions that aren't there.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: question about conditional breaking
2002-09-20 0:36 question about conditional breaking Peter Jay Salzman
2002-09-20 6:46 ` Daniel Jacobowitz
@ 2002-09-20 8:46 ` Kevin Buettner
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Buettner @ 2002-09-20 8:46 UTC (permalink / raw)
To: Peter Jay Salzman, Gdb Mailing List
On Sep 20, 12:36am, Peter Jay Salzman wrote:
> so it appears that here's the rule:
>
> you're allowed to use any function, even library functions, provided that:
>
> 1. the library is linked to your application
> 2. you actually _use_ the function somewhere in your code.
>
> to be honest, i'm not the least surprised by condition 1, but i'm
> shocked by condition 2.
Is the library in question a shared library?
I'm not all that surprised by condition 2 if you attempt to set these
conditional breakpoints prior to running gdb (and thus loading the
shared library).
For library functions which are used by your application, you're able
to find them prior to loading the shared library due to the fact that
these symbols have PLT entries. Once the shared library has been
loaded, you should be able to find other library functions too.
Something to try: Put a breakpoint on main and run the program.
Once the breakpoint has been hit, try adding your conditional
breakpoints. My guess is that you'll be able to add those that
you couldn't previously add.
BTW, I believe that this is the same problem as being unable to put
breakpoints on shared library functions (which are not directly used
by the application) prior to the shared library being loaded.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-09-20 15:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-20 0:36 question about conditional breaking Peter Jay Salzman
2002-09-20 6:46 ` Daniel Jacobowitz
2002-09-20 8:46 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox