Hi,
I am very new to net-snmp and to linux...just what you guys wanted to hear, right? Anyway, I am sure there is a simple answer for this but I have been beating my head against the wall the past few days so if some one could take time to explain how to step into a shared library with gdb, I would very much appreciate it. There is a short version of the question, and a long version below.

My short question is:
How do I set up the environment to allow me to step into my compiled version libnetsnmpagent.so.5 with gdb when there is a system shared library of the same name in the system path? Is there an environment variable in gdb I need to set to have it pick up the right shared module? I tried static linking but I got lost in a maze of link order problems. I would rather get the dynamic debugging going but I am open to static linking if some one could help with the link order. That is a whole other post though....thanks for the help.

Thanks for the help,

Alan L. Anderson
RadiSys
[EMAIL PROTECTED]

************** The same question in long format with research ***********************
It seems that when I set the dynamic linker environment variables to verbose:
setenv LD_VERBOSE t
setenv LD_TRACE_LOADED_OBJECTS t
setenv LD_WARN t

I get what I expect. Before the LD_LIBRARY_PATH is set, I get this.

    bld1-dsm> pwd
    /vobs/vob3/net-snmp/doc/tutorial
    bld1-dsm> ./example-demon
    libnetsnmpagent.so.5 => /usr/lib/libnetsnmpagent.so.5 (0x40023000)
    libnetsnmpmibs.so.5 => /usr/lib/libnetsnmpmibs.so.5 (0x4003a000)
    libnetsnmphelpers.so.5 => /usr/lib/libnetsnmphelpers.so.5 (0x400d5000)
    libnetsnmp.so.5 => /usr/lib/libnetsnmp.so.5 (0x400e6000)
    libdl.so.2 => /lib/libdl.so.2 (0x40167000)
    libcrypto.so.4 => /lib/libcrypto.so.4 (0x4016b000)
    libm.so.6 => /lib/tls/libm.so.6 (0x4025d000)
    libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
    libgssapi_krb5.so.2 => /usr/kerberos/lib/libgssapi_krb5.so.2 (0x4027f000
    )
    libkrb5.so.3 => /usr/kerberos/lib/libkrb5.so.3 (0x40292000)
    libcom_err.so.3 => /usr/kerberos/lib/libcom_err.so.3 (0x402f0000)
    libk5crypto.so.3 => /usr/kerberos/lib/libk5crypto.so.3 (0x402f2000)
    libresolv.so.2 => /lib/libresolv.so.2 (0x40303000)
    libz.so.1 => /usr/lib/libz.so.1 (0x40315000)
After the LD_LIBRARY_PATH is set, I get this:
    bld1-dsm> printenv LD_LIBRARY_PATH /vobs/vob3/net-snmp/tfs/x86/agent/.libs:/vobs/vob3/net-snmp/tfs/x86/snmplib/.libs:/vobs/vob3/net-snmp/tfs/x86/agent/helpers/.libs:/usr/X11R5/lib:/usr/MOTIF/lib
    bld1-dsm>

    /vobs/vob3/net-snmp/doc/tutorial
    bld1-dsm> ./example-demon
    libnetsnmpagent.so.5 => /vobs/vob3/net-snmp/tfs/x86/agent/.libs/libnetsnmpagent.so.5 (0x40017000)
    libnetsnmpmibs.so.5 => /vobs/vob3/net-snmp/tfs/x86/agent/.libs/libnetsnmpmibs.so.5 (0x40048000)
    libnetsnmphelpers.so.5 => /vobs/vob3/net-snmp/tfs/x86/agent/helpers/.libs/libnetsnmphelpers.so.5 (0x400d4000)
    libnetsnmp.so.5 => /vobs/vob3/net-snmp/tfs/x86/snmplib/.libs/libnetsnmp.so.5 (0x400ec000)
    libdl.so.2 => /lib/libdl.so.2 (0x40189000)
    libcrypto.so.4 => /lib/libcrypto.so.4 (0x4018d000)
    libm.so.6 => /lib/tls/libm.so.6 (0x4027f000)
    libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
    libgssapi_krb5.so.2 => /usr/kerberos/lib/libgssapi_krb5.so.2 (0x402a1000
    )
    libkrb5.so.3 => /usr/kerberos/lib/libkrb5.so.3 (0x402b4000)
    libcom_err.so.3 => /usr/kerberos/lib/libcom_err.so.3 (0x40312000)
    libk5crypto.so.3 => /usr/kerberos/lib/libk5crypto.so.3 (0x40314000)
    libresolv.so.2 => /lib/libresolv.so.2 (0x40325000)
    libz.so.1 => /usr/lib/libz.so.1 (0x40337000)
All seems to be cool. But when I try to set a break point in init_agent (resolved in file
    bld1-dsm> gdb example-demon
    GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
    Copyright 2003 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB. Type "show warranty" for details.
    This GDB was configured as "i386-redhat-linux-gnu"...
    (gdb) dir /vobs/vob3/net-snmp/src/agent/:/vobs/vob3/net-snmp/src/agent/helpers:/vobs/vob3/net-snmp/src/snmplib:/vobs/vob3/net-snmp/doc/tutorial
    Source directories searched: /vobs/vob3/net-snmp/src/agent:/vobs/vob3/net-snmp/src/agent/helpers:/vobs/vob3/net-snmp/src/snmplib:/vobs/vob3/net-snmp/doc/tutorial:$cdir:$cwd
    (gdb)
    (gdb) b main
    Breakpoint 1 at 0x8048860: file example-demon.c, line 25.
    (gdb) b init_agent
    Breakpoint 2 at 0x80486c8
    (gdb) run
    Starting program: /vobs/vob3/net-snmp/doc/tutorial/example-demon
    .cshrc
    Terminal type? [xterm]
    Erase is control-H (^H).
    Kill is control-X (^X).
    Breakpoint 2 at 0x4002d714

    Breakpoint 1, main (argc=1, argv=0xbffff064) at example-demon.c:25
    25 snmp_enable_stderrlog();
    (gdb) next
    30 netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
    (gdb)
    17 int agentx_subagent=1; /* change this if you want to be a SNMP master agent */
    (gdb)
    30 netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
    (gdb)
    38 init_agent("example-demon");
    (gdb)

    Breakpoint 2, 0x4002d714 in init_agent () from /usr/lib/libnetsnmpagent.so.5
    (gdb)

Now, for those of you still following this, 'init_agent' is resolved in libnetsnmpagent.so.
    bld1-dsm> nm -l /vobs/vob3/net-snmp/tfs/x86/agent/.libs/libnetsnmpagent.so | grep init_agent
    0000db58 T init_agent /vobs/vob3/net-snmp/src/agent/snmp_vars.c:270
What am I missing? Is there an environment variable in gdb I need to set to have it pick up the right shared module? I tried static linking but I got lost in a maze of link order problems. I would rather get the dynamic debugging going but I am open to static linking if some one could help with the link order. That is a whole other post though....thanks for the help.

Thanks,

Alan L. Anderson
RadiSys ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=click _______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to