Solved

GDB and core files

Posted on 1997-05-11
8
1,535 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
 

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

937 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

Need Help in Real-Time?

Connect with top rated Experts

3 Experts available now in Live!

Get 1:1 Help Now