LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-15-2008, 12:57 PM   #1
akm3
LQ Newbie
 
Registered: Dec 2008
Location: Atlanta GA
Distribution: Ubuntu 8.10
Posts: 11

Rep: Reputation: 0
Debugging an exexutable C program


Dear all,

I have written a simple program using FFMPEG libraries in C, to zero out some packets in a video, and then try to extract its frames.
The program complies without an error in gcc, and gives me an executable file.
When I use the executable file with a video as output, I get no frame.
(While it worked correctly before zeroing packets)
So, it seems the program crashes somewhere.
Is there any capability in gcc, or any other linux IDE, that I can use to find where in my code the executable file crashes?
 
Old 12-15-2008, 02:16 PM   #2
rjwilmsi
Member
 
Registered: Mar 2005
Location: UK
Distribution: opensuse 12.2 x86_64
Posts: 563

Rep: Reputation: 38
Take a look at http://www.kdevelop.org/index.html?f...rated_Debugger
 
Old 12-17-2008, 03:12 PM   #3
akm3
LQ Newbie
 
Registered: Dec 2008
Location: Atlanta GA
Distribution: Ubuntu 8.10
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rjwilmsi View Post
Thank you very much.
So, I have installed KDevelop on my Linux(it is Ubuntu)
Now, I have a code compiled by GCC, and it has given me an executable file.
The input for the executable file is a video file, and the output is the frames of video saved in separate files.
I want to see exactly which functions are called during the run of my executable code.Since the functions in my code should refer to the ones inside the FFMPEG's source code, and I want to see exactly where.
Do you know how can I do it in KDEvelop, or is there some tutorial to teach me doing that?

Thanks again,and sorry since the questions may look a little bit dumb.
 
Old 12-17-2008, 03:36 PM   #4
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,910

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
The 'classic' (ie, ignoring the debugger) way of attacking this kind of problem is to write something to I/O. This may be a 'diagnostic print statement' (assuming you've somewhere to send it...maybe to a printer or to a window on the monitor) or to write to a log file.

it is of course your choice about how much information to write; you may just want to write 'entering routine blah' or you may find 'entering routine blah, data = blur' more helpful.

Usually then the last succesful write is the first one that you want to start pulling to pieces.
 
Old 12-17-2008, 03:58 PM   #5
akm3
LQ Newbie
 
Registered: Dec 2008
Location: Atlanta GA
Distribution: Ubuntu 8.10
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by salasi View Post
The 'classic' (ie, ignoring the debugger) way of attacking this kind of problem is to write something to I/O. This may be a 'diagnostic print statement' (assuming you've somewhere to send it...maybe to a printer or to a window on the monitor) or to write to a log file.

it is of course your choice about how much information to write; you may just want to write 'entering routine blah' or you may find 'entering routine blah, data = blur' more helpful.

Usually then the last succesful write is the first one that you want to start pulling to pieces.
Thanks,
I'm not sure whether I got it right or not, but you mean I modify the functions' bodies so that the write something in a log file when they are called?

If that is the case, it should be really hard, cuz there are tons of functions in the source code, and even lots of .c files, so it is really difficult to change all those files, when you have no idea that it goes to which file, and calls which function among those many choices.


If my understanding is wrong, I appreciate you correcting me.
 
Old 12-18-2008, 06:16 AM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,910

Rep: Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776Reputation: 776
Well, I had more in mind that you would modify the calling program than the function being called; after all, this will probably more useful if your calling program calls the function from several places.

If there are too many places, you would have to make some intelligent guesses about where the problem might be and scatter a few 'prints' around; if you've got it wrong, you'd have to start again scattering new 'prints' around the place, bearing in mind your new knowledge.

Another thought is that the 'prints' may be activated with ifdefs depending on some debugging status; as this can make a mess of the code, you may want to take appropriate measures for removing them once debugging is complete (is this a realistic provision?).
 
Old 12-18-2008, 10:45 AM   #7
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,290

Rep: Reputation: 174Reputation: 174
ddd is an excellent
frontend to gdb
 
  


Reply

Tags
error, executable, files


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with debugging Pascal program wanted. Doctorzongo Programming 4 04-13-2008 05:11 PM
what's the extension of exexutable kernel file? htandel Linux - Newbie 3 05-26-2007 12:05 PM
Debugging C++ so called from java program exitsfunnel Programming 3 10-12-2005 03:01 PM
Debugging Multithreaded Program villie Programming 2 08-17-2004 11:24 AM
program logic comparison and debugging help needed frieza Programming 4 03-12-2004 11:14 PM


All times are GMT -5. The time now is 02:17 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration