LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Others have gdb debug symbols but I don't... (https://www.linuxquestions.org/questions/programming-9/others-have-gdb-debug-symbols-but-i-dont-858162/)

williawh 01-23-2011 12:31 PM

Others have gdb debug symbols but I don't...
 
Using the same platform and the same code compiled with -g
My teammate can logon build the source, run, create a core file
>gdb Exename core.exename.pid
gdb> where
produces a backtrace to the line that the error occurred.

I login and build the same source, run, create a core file
>gdb Exename core.exename.pid
gdb> where
gives me minimal info as if I have no symbols loaded.

Checked our .bashrc and env for differences but find none. What? I give up!

Aquarius_Girl 01-23-2011 09:37 PM

Try this:http://www.delorie.com/gnu/docs/gdb/gdb_125.html

The following quote is from above link:
Quote:

file filename
Use filename as the program to be debugged. It is read for its symbols and for the contents of pure memory.

williawh 01-24-2011 08:27 AM

I will look at the provided link. However, remember that nothing is different except that I login to my account and my teammate logs into their account. They can get useful debug information, I can't. The Exe has the debug info built into it at compile time right? So I understand you are saying use the file command but typically this is not necessary

Aquarius_Girl 01-24-2011 08:28 AM

Quote:

Originally Posted by williawh (Post 4236047)
So I understand you are saying use the file command but typically this is not necessary

Yes, but there is no harm in trying since the cause of the problem is unknown!

williawh 01-25-2011 10:39 AM

Good point Anisha.

The following are my environment variables minus the ones I thought were irrelevant to this topic:
SHELL=/bin/bash
KDE_NO_IPV6=1
GTK_RC_FILES=/etc/gtk/gtkrc:/home/williawh/.gtkrc-1.2-gnome2
QTDIR=/usr/lib64/qt-3.3
QTINC=/usr/lib64/qt-3.3/include
USER=williawh
LD_LIBRARY_PATH=/opt/Xilinx/10.1/ISE/lib/lin64:/usr/X11R6/lib:/opt/Xilinx/10.1/ISE/smartmodel/lin64/installed_lin64:/opt/Xilinx/10.1/ISE/smartmodel/lin64/installed_lin64/lib/linux.lib:/opt/Xilinx/10.1/ISE/smartmodel/lin64/installed_lin64:/opt/Xilinx/10.1/ISE/smartmodel/lin64/installed_lin64/lib/amd64.lib:/opt/Xilinx/10.1/EDK/lib/lin64:/opt/Xilinx/10.1/ISE/lib/lin64:/usr/X11R6/lib:/opt/Xilinx/10.1/ISE/smartmodel/lin64/installed_lin64/lib/linux.lib:/opt/Xilinx/10.1/ISE/smartmodel/lin64/installed_lin64/lib/amd64.lib:/opt/Xilinx/10.1/EDK/lib/lin64
DEPMOD=/opt/eldk/usr/bin/depmod.pl
XILINX_EDK=/opt/Xilinx/10.1/EDK
KDEDIR=/usr
USERNAME=williawh
PATH=/opt/eldk/usr/bin:/opt/eldk/bin:/opt/Xilinx/10.1/EDK/gnu/microblaze/lin64/bin/:/opt/Xilinx/10.1/EDK/gnu/powerpc-eabi/lin64/bin/:/opt/Xilinx/10.1/ISE/bin/lin64:/opt/Xilinx/10.1/EDK/bin/lin64:/opt/Xilinx/10.1/EDK/lib/lin64:/opt/eldk/usr/bin:/opt/eldk/bin:/opt/Xilinx/10.1/EDK/gnu/microblaze/lin64/bin/:/opt/Xilinx/10.1/EDK/gnu/powerpc-eabi/lin64/bin/:/opt/Xilinx/10.1/ISE/bin/lin64:/opt/Xilinx/10.1/EDK/bin/lin64:/opt/Xilinx/10.1/EDK/lib/lin64:/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/williawh/bin
XIL_IMPACT_USE_LIBUSB=1
XMODIFIERS=@im=none
KDE_IS_PRELINKED=1
LANG=en_US.UTF-8
HOME=/home/williawh
LOGNAME=williawh
QTLIB=/usr/lib64/qt-3.3/lib
ARCH=powerpc
CROSS_COMPILE=ppc_4xx-
LMC_HOME=/opt/Xilinx/10.1/ISE/smartmodel/lin64/installed_lin64:/opt/Xilinx/10.1/ISE/smartmodel/lin64/installed_lin64
XILINX=/opt/Xilinx/10.1/ISE

I am compiling to a xilinx powerpc 405 processor board using eldk provided from xilinx using the following Makefile:
PROJ = TEPCdacq
OBJS = Dacq.o ProcessCmd.o Calculation.o Logging.o FPGA_Sim.o\
Analog_Voltage.o Detector.o High_Voltage.o Power.o Pulser.o

LIBS =

CFLAGS =-Wall
CDEFS =

TEPC_DIR = ../..
TEPC_APPS_DIR = $(TEPC_DIR)/apps
TEPC_INCLUDE_DIR = $(TEPC_APPS_DIR)/include
ANALOG_INCLUDE_DIR = $(TEPC_DIR)/modules/analog
DETECTOR_INCLUDE_DIR = $(TEPC_DIR)/modules/detector
HIVOLT_INCLUDE_DIR = $(TEPC_DIR)/modules/hivolt
POWER_INCLUDE_DIR = $(TEPC_DIR)/modules/power
PULSER_INCLUDE_DIR = $(TEPC_DIR)/modules/pulser
PROCESSOR_INCLUDE_DIR = $(TEPC_DIR)/modules/pboard

INCLUDES = -I.
INCLUDES += -I$(TEPC_INCLUDE_DIR)
INCLUDES += -I$(ANALOG_INCLUDE_DIR)
INCLUDES += -I$(DETECTOR_INCLUDE_DIR)
INCLUDES += -I$(HIVOLT_INCLUDE_DIR)
INCLUDES += -I$(POWER_INCLUDE_DIR)
INCLUDES += -I$(PULSER_INCLUDE_DIR)
INCLUDES += -I$(PROCESSOR_INCLUDE_DIR)

DEBUG_MODE = 1

ifeq ($(DEBUG_MODE),1)
CC = $(CROSS_COMPILE)gcc -g
CPLUS = $(CROSS_COMPILE)g++ -g
else
CC = $(CROSS_COMPILE)gcc -O3
CPLUS = $(CROSS_COMPILE)g++ -O3
endif

RM = rm -rf
AR = $(CROSS_COMPILE)ar crus

all: exec

default: exec

DEPS = $(OBJS:.o=.d)
-include $(DEPS)

exec: $(PROJ)
-cp ${PROJ} /opt/eldk/ppc_4xx/home/shared/.

%.o : %.c
$(CC) -M $(CFLAGS) $(INCLUDES) $(CDEFS) -o $*.d $<
$(CC) $(CFLAGS) $(INCLUDES) $(CDEFS) -o $@ -c $<

%.o : %.cpp
$(CPLUS) -M $(CFLAGS) $(INCLUDES) $(CDEFS) -o $*.d $<
$(CPLUS) $(CFLAGS) $(INCLUDES) $(CDEFS) -o $@ -c $<

$(PROJ): $(OBJS)upgrade: $(PROJ)
mkdir tepc_upgrade
cp $(PROJ) $(PROJ).md5 tepc_upgrade/
tar cvzf tepc_upgrade.tgz tepc_upgrade/
rm -rf tepc_upgrade/

clean:
rm -rf ${PROJ} core core.* *.o *.d temp.* *.out typescript* *.md5 tepc_upgrade.tgz tepc_upgrade/
-rm -f /opt/eldk/ppc_4xx/home/shared/${PROJ}

edit-clean : clean
$(RM) *~

$(CPLUS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) -lm
md5sum $(PROJ) > $(PROJ).md5

The produced output from the makefile is as follows:
[williawh@tepc-edev data_acq]$ make
ppc_4xx-gcc -g -M -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Dacq.d Dacq.c
ppc_4xx-gcc -g -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Dacq.o -c Dacq.c
ppc_4xx-gcc -g -M -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o ProcessCmd.d ProcessCmd.c
ppc_4xx-gcc -g -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o ProcessCmd.o -c ProcessCmd.c
ppc_4xx-gcc -g -M -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Calculation.d Calculation.c
ppc_4xx-gcc -g -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Calculation.o -c Calculation.c
ppc_4xx-gcc -g -M -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Logging.d Logging.c
ppc_4xx-gcc -g -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Logging.o -c Logging.c
ppc_4xx-gcc -g -M -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o FPGA_Sim.d FPGA_Sim.c
ppc_4xx-gcc -g -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o FPGA_Sim.o -c FPGA_Sim.c
ppc_4xx-gcc -g -M -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Analog_Voltage.d Analog_Voltage.c
ppc_4xx-gcc -g -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Analog_Voltage.o -c Analog_Voltage.c
ppc_4xx-gcc -g -M -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Detector.d Detector.c
ppc_4xx-gcc -g -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Detector.o -c Detector.c
ppc_4xx-gcc -g -M -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o High_Voltage.d High_Voltage.c
ppc_4xx-gcc -g -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o High_Voltage.o -c High_Voltage.c
ppc_4xx-gcc -g -M -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Power.d Power.c
ppc_4xx-gcc -g -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Power.o -c Power.c
ppc_4xx-gcc -g -M -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Pulser.d Pulser.c
ppc_4xx-gcc -g -Wall -I. -I../../apps/include -I../../modules/analog -I../../modules/detector -I../../modules/hivolt -I../../modules/power -I../../modules/pulser -I../../modules/pboard -o Pulser.o -c Pulser.c
ppc_4xx-g++ -g -Wall -o TEPCdacq Dacq.o ProcessCmd.o Calculation.o Logging.o FPGA_Sim.o Analog_Voltage.o Detector.o High_Voltage.o Power.o Pulser.o -lm
md5sum TEPCdacq > TEPCdacq.md5

cp TEPCdacq /opt/eldk/ppc_4xx/home/shared/.
The exe is copied to a share folder that is NFS mounted on the target.

I run the code and get a core core.TEPCdacq.870:

/aridata/bin # gdb TEPCdacq core.TEPCdacq.870
GNU gdb Red Hat Linux (6.7-1rh)
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "ppc-linux"...
Using host libthread_db library "/mnt/lib/libthread_db.so.1".

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/libstdc++.so.6...done.
Loaded symbols for /lib/libstdc++.so.6
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld.so.1...done.
Loaded symbols for /lib/ld.so.1
Core was generated by `TEPCdacq'.
Program terminated with signal 11, Segmentation fault.
#0 0x3969fffc in ?? ()
(gdb) where
#0 0x3969fffc in ?? ()
Cannot access memory at address 0x801e8104
(gdb)

Doing it the way you suggested... If this is not what you mean please let me know...:

/aridata/bin # gdb
GNU gdb Red Hat Linux (6.7-1rh)
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "ppc-linux".
(gdb) file TEPCdacq
Reading symbols from /aridata/bin/TEPCdacq...done.
Using host libthread_db library "/mnt/lib/libthread_db.so.1".
(gdb) core-file core.TEPCdacq.87
/aridata/bin/core.TEPCdacq.87: No such file or directory.
(gdb) core-file core.TEPCdacq.870
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/libstdc++.so.6...done.
Loaded symbols for /lib/libstdc++.so.6
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld.so.1...done.
Loaded symbols for /lib/ld.so.1
Core was generated by `TEPCdacq'.
Program terminated with signal 11, Segmentation fault.
#0 0x3969fffc in ?? ()
(gdb) where
#0 0x3969fffc in ?? ()
Cannot access memory at address 0x801e8104
(gdb)

I copy the core file to the shared folder:
/aridata/bin # cp core.TEPCdacq.870 /mnt/home/shared/
/aridata/bin # mount
rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw)
proc on /proc type proc (rw)
/dev/xsa2 on /aridata type ext3 (rw,errors=continue,data=ordered)
192.168.1.1:/opt/eldk/ppc_4xx on /mnt type nfs (rw,vers=3,rsize=32768,wsize=32768,namlen=255,hard,nointr,proto=udp,timeo=7,retrans=3,sec=sys,addr=1 92.168.1.1)
/aridata/bin #

I then copy it to the directory I built the source in and run the target debugger: (no joy :| nundeskut!!!)
[williawh@tepc-edev data_acq]$ pwd
/home/williawh/workspace/trunk/tepc_software/apps/data_acq
[williawh@tepc-edev data_acq]$ cp /opt/eldk/ppc_4xx/home/shared/core.TEPCdacq.870 .
cp: cannot open `/opt/eldk/ppc_4xx/home/shared/core.TEPCdacq.870' for reading: Permission denied
[williawh@tepc-edev data_acq]$ cp /opt/eldk/ppc_4xx/home/shared/core.TEPCdacq.870 .
[williawh@tepc-edev data_acq]$ whereis ppc_4xx-gdb
ppc_4xx-gdb:
[williawh@tepc-edev data_acq]$ which ppc_4xx-gdb
/opt/eldk/usr/bin/ppc_4xx-gdb
[williawh@tepc-edev data_acq]$ /opt/eldk/usr/bin/ppc_4xx-gdb
GNU gdb Red Hat Linux (6.7-1rh)
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=ppc-linux".
The target architecture is set automatically (currently powerpc:403)

(gdb) file TEPCdacq
Reading symbols from /home/williawh/workspace/trunk/tepc_software/apps/data_acq/TEPCdacq...done.
(gdb) core-file core.TEPCdacq.870
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /opt/eldk/ppc_4xx/lib/libstdc++.so.6...done.
Loaded symbols for /opt/eldk/ppc_4xx/lib/libstdc++.so.6
Reading symbols from /opt/eldk/ppc_4xx/lib/libm.so.6...done.
Loaded symbols for /opt/eldk/ppc_4xx/lib/libm.so.6
Reading symbols from /opt/eldk/ppc_4xx/lib/libgcc_s.so.1...done.
Loaded symbols for /opt/eldk/ppc_4xx/lib/libgcc_s.so.1
Reading symbols from /opt/eldk/ppc_4xx/lib/libc.so.6...done.
Loaded symbols for /opt/eldk/ppc_4xx/lib/libc.so.6
Reading symbols from /opt/eldk/ppc_4xx/lib/ld.so.1...done.
Loaded symbols for /opt/eldk/ppc_4xx/lib/ld.so.1
Core was generated by `TEPCdacq'.
Program terminated with signal 11, Segmentation fault.
#0 0x3969fffc in ?? ()
(gdb) where
#0 0x3969fffc in ?? ()
Cannot access memory at address 0x801e8104
(gdb) quit


aaaaarrrrrgggggggghhhhhhhhhhhhhhhh! I contacted the system guru. He says "well you must be doing something different... good grief :O !!!

Aquarius_Girl 01-25-2011 11:48 AM

I couldn't properly read your outputs since you didn't use the [code] tags, see what I get by the following commands, try the exact same commands on a simple program like hello.c, and compare the outputs:
Code:

anisha@linux-dpjj:~/Desktop> gcc -Wall -Wextra hello.c -g
anisha@linux-dpjj:~/Desktop> gdb ./a.out
....
Reading symbols from /home/anisha/Desktop/a.out...done.
(gdb) file ./a.out
Load new symbol table from "/home/anisha/Desktop/a.out"? (y or n) y
Reading symbols from /home/anisha/Desktop/a.out...done.
(gdb) b main
Breakpoint 1 at 0x804845d: file check.c, line 5.
(gdb) r
Starting program: /home/anisha/Desktop/a.out
Missing separate debuginfo for /lib/ld-linux.so.2
Try: zypper install -C "debuginfo(build-id)=d7706cbaa0ca09319cb645eac789cb8399078797"
Missing separate debuginfo for /lib/libc.so.6
Try: zypper install -C "debuginfo(build-id)=ee302691046515fe3766ae3b7d47afd3e3a8d063"


Breakpoint 1, main () at check.c:5
5                char *buff[]={"ram","shayam","hari"};
(gdb) generate-core-file ./a.out
Saved corefile ./a.out
(gdb) core-file a.out
A program is being debugged already.  Kill it? (y or n) y
"/home/anisha/Desktop/a.out": not in executable format: File format not recognized
(gdb) core-file a.out
Core was generated by `/home/anisha/Desktop/a.out'.
Program terminated with signal 5, Trace/breakpoint trap.
#0  main () at check.c:5
5                char *buff[]={"ram","shayam","hari"};
(gdb)


williawh 01-26-2011 08:52 AM

could you send me the exact code you used please?

Aquarius_Girl 01-26-2011 08:55 AM

Which code are you talking of? You must not be asking me to paste here a 'hello.c' of course!


All times are GMT -5. The time now is 10:00 AM.