Solved

GDB and core files

Posted on 1997-05-11
8
1,555 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IMAP copying tool 14 76
AWS Linux EC2 question on group 7 88
sed command 3 28
touch cat vi differences 7 34
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

739 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