gnucap-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnucap-devel] Accessing right side vector


From: al davis
Subject: Re: [Gnucap-devel] Accessing right side vector
Date: Fri, 26 Jul 2013 22:44:54 -0400
User-agent: KMail/1.13.7 (Linux/3.2.0-4-amd64; KDE/4.8.4; x86_64; ; )

On Thursday 25 July 2013, Rishabh Yadav wrote:
> I am implementing mrdump command which dumps the right hand
> side matrix values.The problem is when I try to access the
> right side vector,i.e.,_sim->_i[i] it says Segmentation
> fault(core dumped).probably that means _sim->_i does not
> exists when i am trying to reference it.I tested this after
> doing a transient analysis.

That array is deleted before you can print it.
        _sim->unalloc_vectors();

Although the original goal here was spice compatibility (bug-
for-bug) ..  sometimes it just doesn't work.

Some coding advice ...  (the way gnucap is coded, and the way it 
is expected to be done for inclusion in the main package) ..

Use "assert" to verify pointers before using them.  In this 
case:

  assert(_sim);
  assert(_sim->_i);

If you compile with "-DNDEBUG", these become nothing when 
compiled, otherwise instead of a random segfault, it prints a 
message "assert failed".  A "release" build defines NDEBUG, a 
development build does not.  For core, this feature is 
implemented in both the static and autotools build systems.

Also, when debugging, it is best to compile with optimization 
off (-O0)  (dash Oh Zero) .

Now a question ....  Is there any real reason, other than for 
this command, to keep them around?

Aside from Spice compatibility, I think the best way to do the 
dump is as an option to the dc/ac/tran command.

For the summer of code project ..... since there are lots of 
others, skip this one.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]