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
Solved

GDB

Posted on 2003-10-21
7
314 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Test against App 49 138
C++ finding a sting in a char* string from a text file 3 120
Constant string is of type char *   ? 7 42
NEED HELP WITH VISUAL STUDIO 2017 (beginner) 6 65
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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

856 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