Solved

GDB

Posted on 2003-10-21
7
313 Views
Last Modified: 2010-04-15
with GDB, i think I should be able to directly call a function in my program then trace the flow step by step.

However, when the parameters of the function are very complicated, such as structures(within the structure, its
members can be structures too) instead of simple data type such as int or ulong, what can I do in this case in order
to debug this function?

Seems there is just no way out?

Thx!
0
Comment
Question by:codenamecharlie
  • 4
7 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9596844
Hi codenamecharlie,

set a break point at the first line of function ... b filename:line_number
run the program ... r
to examine the structs passed, use print
p struct_name->element


Cheers!
Sunny:o)
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9596866
>when the parameters of the function are very complicated, such as structures(within the structure, its
>members can be structures too) instead of simple data type such as int or ulong,

you might also like to set a watch if you doubt that one particular element is bein manipulated incorrectly

otherwise, setting break points and using print is the best option

If you feel more comfortable with GUIs then look into ddd .. it is the graphical front to gdb
0
 
LVL 23

Accepted Solution

by:
brettmjohnson earned 50 total points
ID: 9596891
I think sunnycoder misinterpreted your question (or perhaps I did)

I believe you want to call a function directly from the gdb  prompt as such:

gdb> p somefunction(anInt)

which is easy if somefunction() takes an int parameter.  However if it takes
a very complex data type, that data is hard to mock up using gdb commands.

What I have done in that case is to set a breakpoint in my program logic after
the complex data structure has been created.  Then manually call somefunction,
passing the data structure constructed.

0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 45

Expert Comment

by:sunnycoder
ID: 9596898
oops .. looks like I misinterpreted it
0
 

Author Comment

by:codenamecharlie
ID: 9596909
hi brettmjohnson,

yes, sunnycoder misinterpreted my Q and your understanding is correct.
Your way might be a way out.. i will look into it. Thx
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9886759
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:
PAQed with A grade to brettmjohnson

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Sunny
EE Cleanup Volunteer
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C: GetDiskFreeSpaceEx() for default drive 14 107
Digital Output does not have continuity to ground? 3 90
Global Keyboard Hooks Blocked 4 75
delete-remove 14 84
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

815 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

10 Experts available now in Live!

Get 1:1 Help Now