Solved

GDB and core files

Posted on 1997-05-11
8
1,542 Views
Last Modified: 2013-12-06
Sometimes when I compile programs so that I can debug the core file, I get a strange error message. For example, on a recent program of mine called orange, the command gdb orange core produced the following message:

Couldn't fetch registers from core file: file in wrong format.

Can anyone say what this means? Is there some esoteric switch I need to use with gdb?
0
Comment
Question by:ventnor
8 Comments
 
LVL 19

Expert Comment

by:xterm
ID: 1626251
You can also start with both an executable program  and  a
       core file specified:

       gdb program core

(from the gdb man page) so the answer is no to the "esoteric
switch" - does Orange have debugging info compiled in?

0
 

Author Comment

by:ventnor
ID: 1626252
Yes, I hope I'm not so stupid as to forget to compile debugging info in!!
0
 
LVL 1

Expert Comment

by:strobert
ID: 1626253
do a file both on the core and your program the types should match (both a.out or both elf)... does your program change dirs? (thinking it might be dumping core other than where the executable is)
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:ventnor
ID: 1626254
strobert: no, my program doesn't change directories. It's listed below (it's a simple buffer overflow program that I wrote for testing gdb; it's supposed to dump core).

include <syslog.h>
char buffer[4028];

   void main() {

   int i;
   for (i = 0; i<=6745; i++)
   buffer[i]='A';
   syslog(LOG_ERR, buffer);
               }

What I did then was compile the program using the -g switch:

gcc -g -o buff buff.c

I ran buff, and core was dumped. I then fired up gdb:

gdb buff core

And the message came up as above.
0
 
LVL 1

Expert Comment

by:strobert
ID: 1626255
what gcc/gdb version?
I just tried the code on a Redhat 4.0 machine (gcc 2.7.2 gdb 4.16), and it works great
did you ever try doing a file buff and a file core?

0
 

Author Comment

by:ventnor
ID: 1626256
strobert,

My version of gcc is 2.7, and my version of gdb is 4.15.1 When I do file core, I get the message "not in executable format: File format not recognised". When I do file buff, I get the prompt "Load new symbol table from "buff" y or n"

Hope this helps to throw light on the mystery....
0
 
LVL 1

Accepted Solution

by:
hcheng earned 50 total points
ID: 1626257
Your gdb is too old.  You need gdb 4.16.  I had this error after I upgraded my gcc from 2.6.* to 2.7.*, but before my gdb was upgraded.

0
 

Author Comment

by:ventnor
ID: 1626258
Thanks, I guessed something like that was the problem. The only reason I'm not awarding an "excellent" is that it would have been interesting to know why the older version of gdb doesn't work.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question