Solved

GDB

Posted on 2003-10-21
7
312 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

867 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

12 Experts available now in Live!

Get 1:1 Help Now