473,378 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Help with function parameters...

I have a piece of code that calls a function like this:

722 combine_impedance(&el, f);
(gdb) print f
$15 = 12

'el' is a locally defined struct and f is locally defined as double.
One step more gives:

(gdb) s
combine_impedance (el=0x0, f=-30) at chart.c:516
516 {

The parameters are incorrect - I suspect this may have something to do
with
optimization. A few steps more gives:

(gdb) print *el
$18 = {conn = 0, typ = 4, useloss = 0, val1 = 1234, val2 = 0, z0 = 55,
vf = 0,
loss1 = 0, loss2 = 0, mhz1 = 0, mhz2 = 0, ptlst = 0x0, lnlst = 0x0}
(gdb) print f
$19 = nan(0x8000000000000)

*el is now correct, but 'f' isn't. Still optimization problem?

Needless to say, the results from the function are incorrect.

Someone has any idea how to proceed?
JohnC

Nov 14 '05 #1
4 1013

On Tue, 10 May 2005 jo**********@gmail.com wrote:

I have a piece of code that calls a function like this:

722 combine_impedance(&el, f);
(gdb) print f
$15 = 12


I suspect that your C code has an error in line 42; possibly you have
an extra 'z' in the identifier 'wuzzmatuzz'.

Post your code or nobody will be able to help you with it. Also, don't
use Google Groups Beta, or you risk irking a lot of Usenet readers with
your posts' apparent newbieness (wrong quoting levels, "..." in place
of e-mail addresses, etc.). I recommend getting a real newsreader.

-Arthur
please http://www.contrib.andrew.cmu.edu/~a...t-be-evil.html
Nov 14 '05 #2

<jo**********@gmail.com> wrote
I have a piece of code that calls a function like this:

722 combine_impedance(&el, f);
(gdb) print f

Someone has any idea how to proceed?

Personally I can never get any sense out of debuggers. There may be other
people on the group who can use them.

The best debugging tool is the diagnostic printf(). If you suspect your
function has been called with bad parameters, simply print them out on
program entrance (sometimes you need to put an exit() in there to avoid
getting too many printouts).
If the parameters are corrupt, you know that the function itself is probably
OK and something is wrong elsewhere. If they are fine, then print out some
of the local variables at various stages in execution and try to see where
the function is going wrong.
Nov 14 '05 #3
Thanks. I did some printf's and got some interesting results that
pointed me in the right direction.
Though I regularly use gdb, I was really surprised (and confused) about
the weird results I had during this trace. I guess the solution would
be to turn of the optimization before gdb-ing.
Appreciate for the hint.
John

Nov 14 '05 #4
In article <11**********************@f14g2000cwb.googlegroups .com>
<jo**********@gmail.com> wrote:
[While examining code and data with a debugger]
The parameters are incorrect - I suspect this may have something
to do with optimization. A few steps more [and the parameter that

was strange earlier is now normal, while that which was normal
earlier is now strange.]

Unfortunately, dealing with debuggers is off-topic in comp.lang.c
(priarily because there is no standard, C or otherwise, for
debuggers, so you need a *.<debugger-name>.* newsgroup). But
see also <http://web.torek.net/torek/c/compiler.html> (the part
about debugging).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sandie Towers | last post by:
We use a number of similar databases and frequently create a new database using a backup restore of another similar database. We try to keep changes between databases in _Additional tables - like...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
9
by: hope | last post by:
Hi Access 97 I'm lost on this code please can you help ================================= Below is some simple code that will concatenate a single field's value from multiple records into a...
7
by: Advocated | last post by:
Hey all, thanks for taking the time to read this in the first place. Anyway, ill try and keep it simple. In my program, if i type $ man something it should read in the 2 words, man and something...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
0
by: Edwinah63 | last post by:
Hi guys, i am not new to vb6, but a mere tyro in vb.net what i want to do is the following open transaction build an ADODB command object using parameters execute it build another command...
0
by: jennifer.perkins | last post by:
I've seen a couple posts by people having similar problems, but the suggested solutions I've tried so far haven't worked. I'm using a SOAP client in VB.Net (constructed by wsdl.exe) and the...
0
by: jim4u | last post by:
Hi gurus, I have an automation add-in created using C# for Excel, in which I am exposing a number of functions. Is there any way I can add help-text the way excel does for other categories like...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.