Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

GDB and core files

Posted on 1997-05-11
8
Medium Priority
?
1,589 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 100 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

963 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