Next Meeting: July 7: Social gathering Next Installfest: TBD Latest News: Jun. 14: June LUGOD meeting cancelled Page last updated: 2002 Sep 20 11:00
Re: [vox-tech] gdb conditional breaking

# Re: [vox-tech] gdb conditional breaking

```On Thu, 19 Sep 2002, Peter Jay Salzman wrote:

>
> hi lugod,
>
> 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 of all, you can use all the boolean expressions you'd expect to be
> able to use.
>
> break 1 if x > 0
> break 2 if y <= x
>
> parenthesis seem to be purely optional.
>
> break 3 if (! x >= -1)
>
>
> but there's more to the story.  you can use functions too.  here's a
> test program:
>
> #include <math.h>
>
> int main(void)
> {
>    double i = 0.0;
>    double j = M_PI;
>    double k = -1;
>
>    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's a solution to one of the angular equations
> that comes out of separation of variables of laplace's equation in
> spherical coordinates.
>
> but anyway...
>
> you can use functions, like math 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:
>
> 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
> very surprised by condition 2.

Why?

For static linking: Modules are the code units that compile into object
files. Libraries are archives of object files.  During the linking
process, only those object files with symbols that are needed for your
program, or to support routines already extracted from the library, are
actually extracted from the library.  Typically, libraries will be broken
down into one function per object file to minimize unnecessary loading of
code.  Thus, linking against a library does not necessarily jglom the

For dynamic linking (shared libraries), only symbol information for those
functions that you use (directly or indirectly) will be present in your
compiled program, since there is no need to store unused symbols
there.  Lacking symbol information in the obvious place, why should gdb go
looking elsewhere for information that is not likely to be used?

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...2k
---------------------------------------------------------------------------

_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech

```