LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   cannot debug with gdb (https://www.linuxquestions.org/questions/programming-9/cannot-debug-with-gdb-720765/)

ufmale 04-21-2009 05:43 PM

cannot debug with gdb
 
I downloaded a project from the Internet and tried to debug it, but run into a problem.
Without knowing much about the makefile, i managed to copy the part where it build the executable I need.

The problem is that I cannot use gdb with this executable for some reason. However, running the it without gdb seems to work ok.
Can someone help me identifying what I did incorrectly.

Below is what it shows when compiling and link.

Compile:

Code:

gcc -g -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\"
-DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"sphinx3\"
-DVERSION=\"0.7\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1
-DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_MEMMOVE=1
-DHAVE_BCOPY=1 -DRETSIGTYPE=void -DHAVE_DLFCN_H=1  -I. -I. -I../../include
-I../../include  -I/home/user1/cmuspeech/tutorial/sphinx3/../sphinxbase/include
-I/home/user1/cmuspeech/tutorial/sphinx3/../sphinxbase/include  -g -O3 -Wall
-MT main_decode.o -MD -MP -MF ".deps/main_decode.Tpo" \
  -c -g -o  main_decode.o  main_decode.c

Link:

Code:

/bin/sh ../../libtool --mode=link gcc  -g -O3 -Wall 
-L/home/user1/cmuspeech/tutorial/sphinx3/../sphinxbase/src/libsphinxfe
-L/home/user1/cmuspeech/tutorial/sphinx3/../sphinxbase/src/libsphinxad             
-L/home/user1/cmuspeech/tutorial/sphinx3/../sphinxbase/src/libsphinxbase -o
sphinx3_decode  main_decode.o ../../src/libs3decoder/libs3decoder.la
-lsphinxbase -lsphinxad -lm
gcc -g -O3 -Wall -o .libs/sphinx3_decode main_decode.o 
-L/home/user1/cmuspeech/tutorial/sphinx3/../sphinxbase/src/libsphinxfe
-L/home/user1/cmuspeech/tutorial/sphinx3/../sphinxbase/src/libsphinxad
-L/home/user1/cmuspeech/tutorial/sphinx3/../sphinxbase/src/libsphinxbase
../../src/libs3decoder/.libs/libs3decoder.a
/home/user1/cmuspeech/tutorial/sphinx3/../sphinxbase/src/libsphinxbase/.libs/libsphinxbase.so
/home/user1/cmuspeech/tutorial/sphinx3/../sphinxbase/src/libsphinxad/.libs/libsphinxad.so
/home/user1/cmuspeech/tutorial/sphinxbase/src/libsphinxbase/.libs/libsphinxbase.so
-lasound -lpthread -lblas -llapack -lm -Wl,--rpath -Wl,/usr/local/lib


- Running without gdb as following works fine with :
./sphinx3_decode

- Output from gdb (problem):

Code:

[user1@user11 programs]$ gdb sphinx3_decode
GNU gdb Red Hat Linux (6.3.0.0-1.63rh)
Copyright 2004 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"..."/home/user1/workspace/sphinx3/src/programs/sphinx3_decode": not in executable format: File format not recognized

(gdb) run
Starting program:
No executable file specified.
Use the "file" or "exec-file" command.
(gdb) file sphinx3_decode
"/home/user1/workspace/sphinx3/src/programs/sphinx3_decode": not in executable format: File format not recognized
(gdb) exec-file sphinx3_decode
"/home/user1/workspace/sphinx3/src/programs/sphinx3_decode": not in executable format: File format not recognized


I forgot to let you know that I was able to debug a simple helloworld program using gdb, but still cannot debug this sphinx3_decode.

rriggs 04-21-2009 07:30 PM

What does the output of "file ./sphinx3_decode" say?

ufmale 04-22-2009 09:45 AM

Quote:

Originally Posted by rriggs (Post 3516735)
What does the output of "file ./sphinx3_decode" say?


It returns an output as i expected.

ta0kira 04-22-2009 03:06 PM

What does gcc -v say? What happens if you get rid of -O3?
Kevin Barry

paulsm4 04-22-2009 03:18 PM

Boy, that's a really helpful response:
Quote:

Quote:

Originally Posted by rriggs
What does the output of "file ./sphinx3_decode" say?
It returns an output as i expected.
Hint: Please cut and paste the actual output, ufmale!!!!

ufmale 04-23-2009 01:19 PM

Quote:

Originally Posted by paulsm4 (Post 3517600)
Boy, that's a really helpful response:


Hint: Please cut and paste the actual output, ufmale!!!!

Sorry. I miss read the question. Here is the result. I will try to remove the O3 and see what happen.

Code:

$ file ./sphinx3_decode
./sphinx3_decode: Bourne shell script text executable


ufmale 04-23-2009 01:29 PM

It works now.
I have to use

$ libtool gdb ./sphinx3_decode

Not really sure what the different it makes when adding libtool.

ufmale 04-24-2009 11:19 AM

My problem now is how to use that command in Eclipse.
I have tried couple of things, but still cannot get it to work.

paulsm4 04-24-2009 11:29 AM

Hi -

Quote:

$ file ./sphinx3_decode
./sphinx3_decode: Bourne shell script text executable
"sphinx3_decode" is a shell script
You can only run the GDB debugger on binary executables, not shell scripts!

PS:
In case you were wondering, you can't run the Visual Studio debugger on a DOS .bat file, either...

ufmale 04-27-2009 05:21 PM

I felt so silly :) you are right. it is a script file.


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