LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-21-2009, 06:43 PM   #1
ufmale
Member
 
Registered: Feb 2007
Posts: 385

Rep: Reputation: 30
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.

Last edited by ufmale; 04-21-2009 at 06:47 PM.
 
Old 04-21-2009, 08:30 PM   #2
rriggs
Member
 
Registered: Mar 2009
Location: Colorado, US
Distribution: Fedora 13, Fedora 14, RHEL6 Beta
Posts: 46

Rep: Reputation: 17
What does the output of "file ./sphinx3_decode" say?
 
Old 04-22-2009, 10:45 AM   #3
ufmale
Member
 
Registered: Feb 2007
Posts: 385

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by rriggs View Post
What does the output of "file ./sphinx3_decode" say?

It returns an output as i expected.
 
Old 04-22-2009, 04:06 PM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
What does gcc -v say? What happens if you get rid of -O3?
Kevin Barry
 
Old 04-22-2009, 04:18 PM   #5
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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!!!!

Last edited by paulsm4; 04-22-2009 at 11:59 PM.
 
Old 04-23-2009, 02:19 PM   #6
ufmale
Member
 
Registered: Feb 2007
Posts: 385

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by paulsm4 View Post
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
 
Old 04-23-2009, 02:29 PM   #7
ufmale
Member
 
Registered: Feb 2007
Posts: 385

Original Poster
Rep: Reputation: 30
It works now.
I have to use

$ libtool gdb ./sphinx3_decode

Not really sure what the different it makes when adding libtool.
 
Old 04-24-2009, 12:19 PM   #8
ufmale
Member
 
Registered: Feb 2007
Posts: 385

Original Poster
Rep: Reputation: 30
My problem now is how to use that command in Eclipse.
I have tried couple of things, but still cannot get it to work.
 
Old 04-24-2009, 12:29 PM   #9
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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...

Last edited by paulsm4; 04-24-2009 at 12:30 PM.
 
Old 04-27-2009, 06:21 PM   #10
ufmale
Member
 
Registered: Feb 2007
Posts: 385

Original Poster
Rep: Reputation: 30
I felt so silly you are right. it is a script file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I debug the interactinve program with GDB bigapple Programming 1 08-03-2005 10:55 PM
How to use gdb to debug child process? ariana Programming 2 05-03-2005 02:50 PM
GDB unable to debug pthreads linuxdeveloper Programming 1 03-06-2005 06:18 AM
Using gdb to debug different arhitectures george_mercury Linux - Software 1 01-07-2005 07:19 PM
how to debug multithread using GDB? ryanux Programming 1 05-11-2004 01:58 AM


All times are GMT -5. The time now is 08:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration