LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-23-2013, 04:04 PM   #1
atlantis43
Member
 
Registered: Feb 2013
Posts: 289

Rep: Reputation: Disabled
gdb "no Executable File"


Currently taking an online course which provides VMWare Player with gdb. I'm using WinXP pro, Intel on a pc.
"strings" is a binary file, and my terminal is in the appropriate directory
Whenever I attempt debug with cmd '(gdb) r ./filename I get the following:
(gdb) r ./strings
Starting program: ./strings
No executable file specified.
Use the "file" or "exec-file" command.

Could someone explain what might be wrong to cause the above, and what I might do to correct it.
Also, how does one "use the 'file' or 'exec-file' command, if this will help solve the problem.

What might be addn'l info regarding this problem, the "make" cmd in my compiler runs:
"clang -ggdb3 -O0 -std=c99 -Wall -Werror" with some additional remarks.

Hope that someone can help make this functional.
 
Old 02-23-2013, 07:59 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Is there execution permission for strings file?
Code:
[user@example]~$ ls -la /path/to/strings
If not, then once do:
Code:
[user@example]~$ chmod +x /path/to/strings
After this invoke your gdb cmd again and check.

Last edited by shivaa; 02-23-2013 at 08:01 PM.
 
Old 02-23-2013, 08:08 PM   #3
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
(gdb) file ./strings
(gdb) r
 
Old 02-23-2013, 08:49 PM   #4
atlantis43
Member
 
Registered: Feb 2013
Posts: 289

Original Poster
Rep: Reputation: Disabled
Shiva cmds give following response on my terminal:
jharvard@appliance (~/src2w): [user@example]~$ ls -la /path/to/strings
bash: [user@example]~$: command not found

jharvard@appliance (~/src2w): [user@example]~$ chmod +x /path/to/strings
bash: [user@example]~$: command not found
>>>>>>>>>>>>>>
I don't really know what you mean by execution permission, but I can successfully write and run the code on the terminal.

L Root suggestions give the following terminal screen:
>>>>>>>>>>>
(gdb) ./strings: No such file or directory.
Undefined command: "". Try "help".
(gdb) (gdb) r
Undefined command: "". Try "help".
(gdb) Starting program:
Undefined command: "Starting". Try "help".
(gdb) No executable file specified.
(gdb) Use the "file" or "exec-file" command.
 
Old 02-23-2013, 08:56 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
shivaa's example was just showing you the standard linux command prompt, you weren't supposed to actually run the "[user@example]~$" part. He even put it in green to separate it from the actual command. Many of the replies you receive on Linux forums will give some kind of command prompt in the replies. This separates the command you're supposed to run from the expected output from that command. For example, if I were to write:
Code:
date
Sat Feb 23 19:58:38 MST 2013
You wouldn't know what was the command vs what was the expected output. However, if I were to write:
Code:
$ date
Sat Feb 23 19:58:38 MST 2013
or
Code:
[user@example]~$ date
Sat Feb 23 19:58:38 MST 2013
You now know what was the command vs what was the expected output.

You need to run the command itself, "ls -la /path/to/strings" and "chmod +x /path/to/strings". Ignore the "[user@example]~$" since that's just an example command prompt.

Last edited by suicidaleggroll; 02-23-2013 at 09:09 PM.
 
Old 02-23-2013, 09:00 PM   #6
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by atlantis43 View Post
jharvard@appliance (~/src2w): [user@example]~$ ls -la /path/to/strings
bash: [user@example]~$: command not found

jharvard@appliance (~/src2w): [user@example]~$ chmod +x /path/to/strings
bash: [user@example]~$: command not found
http://www.phrases.org.uk/meanings/311200.html

Code:
ls -la /usr/bin/strings
 
Old 02-23-2013, 09:10 PM   #7
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
@atlantis43:
Wait.. Wait... as suicidaleggroll mentioned, [user@example]~$: is NOT part of the original command(s). Its just prompt which I used in my example for clarity. And /path/to/strings means full path of the strings file, like /home/foo/bar/strings.

Anyway, you simply need to run following commands:
Code:
ls -la ./strings
chmod +x ./strings
And after this, run your gdb command like you were running before.

Quote:
A personal suggestion: Do not follow any post blindly. Read it, think about it, understand it, and if you feel it's safe to execute it, then only run it on your terminal. A wrong command may destroy your system in seconds, so beware of running any command without understanding it's purpose.

Last edited by shivaa; 02-23-2013 at 09:12 PM.
 
Old 02-23-2013, 09:14 PM   #8
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by shivaa View Post
A personal suggestion: Do not follow any post blindly. Read it, think about it, understand it, and if you feel it's safe to execute it, then only run it on your terminal. A wrong command may destroy your system in seconds, so beware of running any command without understanding it's purpose.
Always good advice

While I've never seen a malcontent post on LinuxQuestions, blindly executing any command posted by a stranger, without understanding what you're running or why, is never a good thing.

While we're on the subject, it's about time to familiarize yourself with the "man" command. Man stands for "manual", and when run with the name of a command you're curious about, it will give you the manual of that command so you can see what it does, what the various switches are and what they do, etc.

For example, take the
Code:
$ ls -la ./strings
command presented earlier

Code:
$ man ls
will bring up the manual for ls. The first section is:
Code:
NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List  information  about the FILEs
Then you can search for -l or -a to find out what those switches do (you search with "/", so to search for -l just type "/-l" and use "n" to step forward or "N" to step backward through the matches until you find the description for the -l flag:
Code:
-l     use a long listing format
and
Code:
-a     do not ignore entries starting with .
This lets you know that the
Code:
$ ls -la
command will print out the the contents of the file/directory you give it using long-listing format without ignoring any entries starting with . (files starting with "." are typically hidden from the ls output, like your typical Windows "hidden files".

Last edited by suicidaleggroll; 02-23-2013 at 09:31 PM.
 
Old 02-23-2013, 10:35 PM   #9
atlantis43
Member
 
Registered: Feb 2013
Posts: 289

Original Poster
Rep: Reputation: Disabled
thanks to all for clarifications. none of the suggestions given seem to help, though perhaps I don't fully understand them. [I am correctly listed as a novice :-)]
I know that there is program 'strings.c' (compiled) and 'strings' (binary), both present in file ~/src2w/filename. -ls shows both files present where they're supposed to be. Still doesn't explain why gdb can't execute them.
 
Old 02-24-2013, 12:10 AM   #10
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Can you post output of:
Code:
ls -la ~/src2w/filename/*strings*
ls -la ~/src2w/*strings*
Also once go through this and post what error(s) you're getting now.
 
Old 02-24-2013, 07:32 AM   #11
atlantis43
Member
 
Registered: Feb 2013
Posts: 289

Original Poster
Rep: Reputation: Disabled
Shivaa;
running your suggestions on code named "factorial", I get following results:
>>>>>>>>>>>>>>>
jharvard@appliance (~): ls -la ~/src2w/*factorial*
-rwx------. 1 jharvard students 10642 Feb 22 10:56 /home/jharvard/src2w/factorial
-rw-r--r--. 1 jharvard students 332 Feb 22 09:05 /home/jharvard/src2w/factorial.c
>>>>>>>>>>>>>>>>>
(what are those asterisks for, anyway)
then, when gdb run on this file:
>>>>>>>>>>>>
(gdb) r ./factorial
Starting program: ./factorial
No executable file specified.
Use the "file" or "exec-file" command.
>>>>>>>>>>>>>>
I've gotten this result previously, have looked in the man for file cmd, etc, but don't have the understanding of what the info means.

In addition, now having looked at the manual with a little better understanding, I get the following info about the file:
>>>>>>>>>>
jharvard@appliance (~/src2w): file factorial
factorial: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped

Hope this helps further in determining what my problem is.

Last edited by atlantis43; 02-24-2013 at 07:55 AM.
 
Old 02-24-2013, 08:02 AM   #12
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Once invoke these two commands:
Code:
chmod a+x /home/jharvard/src2w/factorial 

chmod a+x /home/jharvard/src2w/factorial.c
And then invoke:
Code:
(gdb) r ./factorial
 
Old 02-24-2013, 08:19 AM   #13
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
The OP is apparently not giving correct commands to gdb. That fact has been buried in this thread by all the focus on checking whether the executable file is valid. There is no reason to believe anything is wrong with the file.

I think this early reply was correct but ignored
http://www.linuxquestions.org/questi...8/#post4898436

Here is a link to the relevant part of the gdb documentation:
http://uw714doc.sco.com/cgi-bin/info...arting&lang=en

You can specify the executable to be debugged on the command line that starts gdb, or you can specify it with a file command inside gdb. But you cannot specify it as a parameter to the r command in gdb.

Last edited by johnsfine; 02-24-2013 at 08:21 AM.
 
1 members found this post helpful.
Old 02-24-2013, 08:20 AM   #14
atlantis43
Member
 
Registered: Feb 2013
Posts: 289

Original Poster
Rep: Reputation: Disabled
OK, so I did the following (with no evident results, though I didn't know what to expect)
jharvard@appliance (~): chmod a+x /home/jharvard/src2w/factorial
jharvard@appliance (~): chmod a+x /home/jharvard/src2w/factorial.c

and then did:
(gdb) No executable file specified.
(gdb) Use the "file" or "exec-file" command.
Undefined command: "Use". Try "help".

Not looking promising!
 
Old 02-24-2013, 08:33 AM   #15
atlantis43
Member
 
Registered: Feb 2013
Posts: 289

Original Poster
Rep: Reputation: Disabled
Johnsfine attention to detail indeed worked. lroot's 2-liner was the answer, and I now have GDB working.
Don't understand why I have to run gdb in this fashion (as compared to what was given in the course's online instructions), but perhaps the link to the gdb documentation will answer that.

Only remaining question is whether I will have to use that format for engageing gdb for each program I might want to debug?
 
  


Reply



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
[SOLVED] cant make a file executable by terminal typing "chmod +x layerfx.py" froylan Ubuntu 3 07-26-2012 02:41 PM
gdb says "cannot open shared object file" mihk Programming 1 05-31-2009 01:10 PM
gdb giving "Not executable format" error with .so paulc4 Programming 4 04-06-2009 07:32 AM
gdb "not in executable format: File format not recognized" tcma Programming 9 07-18-2007 06:02 AM
gdb error "Failed to read a valid object file image from memory." Fejimush Programming 0 03-11-2007 01:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:18 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
Open Source Consulting | Domain Registration