LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   gdb "no Executable File" (https://www.linuxquestions.org/questions/linux-newbie-8/gdb-no-executable-file-4175451438/)

atlantis43 02-23-2013 04:04 PM

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.

shivaa 02-23-2013 07:59 PM

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.

linosaurusroot 02-23-2013 08:08 PM

(gdb) file ./strings
(gdb) r

atlantis43 02-23-2013 08:49 PM

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.

suicidaleggroll 02-23-2013 08:56 PM

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.

linosaurusroot 02-23-2013 09:00 PM

Quote:

Originally Posted by atlantis43 (Post 4898451)
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

shivaa 02-23-2013 09:10 PM

@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.

suicidaleggroll 02-23-2013 09:14 PM

Quote:

Originally Posted by shivaa (Post 4898470)
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".

atlantis43 02-23-2013 10:35 PM

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.

shivaa 02-24-2013 12:10 AM

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.

atlantis43 02-24-2013 07:32 AM

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.

shivaa 02-24-2013 08:02 AM

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

johnsfine 02-24-2013 08:19 AM

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.

atlantis43 02-24-2013 08:20 AM

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!

atlantis43 02-24-2013 08:33 AM

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?


All times are GMT -5. The time now is 12:06 PM.