Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28592 Discussions

How to write an array into a file in idb

afellow
Novice
710 Views
I am dealing with very large arrays, and it would be very helpful to plot them whendebugging. DDD seems to do such things but it is too buggy and very slow for large arrays. I would like to write it into a file (ASCII/Binary) and plot with gnuplot or matlab. Is there any way to do so in idb?

If I can use "print" command and redirected the result into a file, that would be also cool. But I don't know how to make it either.

I know in gbd, there is a command called
"dump value filename arrayname",
which write an array into a binary file,
but it is not supported in idb.

Any ideas would be welcome. It has bothered me for a very long time.

Thanks.
0 Kudos
5 Replies
jimdempseyatthecove
Honored Contributor III
710 Views
afellow,

Have you thought of using the preprocessor and some macros?

#ifdef _DEBUG
#define DEBUG_REFRESH if(Debug_Refresh) call doDebug_Refresh()
#endif

Then insert into your

...
...
DEBUG_REFRESH
...
...
DEBUG_REFRESH

The refresh code goes away in Releas Build.
If you make the logical variable Debug_Refresh SAVE per routine using DEBUG_REFRESH then you can enable/disable the refreshing per module.

Jim Dempsey
0 Kudos
afellow
Novice
710 Views
I think maybe you misunderstand my problem. I am using idb to debug my code.
Your way is helpful but not convenient.
Since that Idefinedlot of arrays, when I following the code and stop somewhere in idb, suddenly I want to have a look at an array to see if it is what I expected. For small arrays, I can print them out to have a look, but for large arrays, this is not helpful.
0 Kudos
jimdempseyatthecove
Honored Contributor III
710 Views
I do understand your problem.

You want an ad-hoc means (after the fact means) of examining large array data. Intel on Windows used to have an add-on that did this: Array Visualizer. Which is no longer supported and never made it into Linux.

Often, when you have a problem you setup a debug session, and go to work debugging. I suggested that (for a limited number of circumstances) you can insert debug helper statements into your code, similar to inserting conditional "write(*,*) x,y,x" diagnostic statements but where these diagnostic statements update data that can be viewed by a different process.

In the Array Visualizer, which you do not have, but which you could implement a subset thereof, you launch the viewer that runs as a seperater process but has access to your process's data (e.g. memory mapped file or other shared memory technique).Running as a different process, it can do so independent of your application which may also be in the process of runningin the debugger. The debugger attachesto your process in a similar way. You would attach your viewer in a similar way. Your application though would have to publish the items you want to watch. TheArray Visualizer did this by way of a sharedHTML file initialized at program start or reused from last run. Although to implement this yourself would be a lot of work, you might do some Google-ingto see if there is a Linux Array Visualizer-like app out there that you can use for debugging (although this would be an overlooked feature not listed in their list of features).

Start your internet search here: http://www.hdfgroup.org/tools.html

Jim Dempsey
0 Kudos
afellow
Novice
710 Views
In another word, there is no easy way? In that case, I will work on your suggestion, andhopefullyI can make it into an handy tool.
Thanks for the suggestion.
0 Kudos
afellow
Novice
710 Views
I try to work on this, but find no way to grab anything information outside from idb. It is like a blackbox and does not communicate a single information with anyone else.
For example, I want to get someinformationlike the shape of an array and theinitialaddress of it, so that I can use the external program to work on this piece of memory. But I find it hard to send the information outside.I can use:

record output filename
some command for information
unrecord output

but it only works in dbx mode, which I am not familiar. Besides, I don't like this method of logging very much, because it feels odd.

So the question is:
Is there any way to communicate with idb through file, pipe, anything? In another word, is there any way to let the other program know what is the current output of idb?

Thanks

0 Kudos
Reply