Reading DWARF file in Mac OSX - dwarf

Can anybody help me writing a program which can read DWARF files and gives me the file name, line number and function name details.

The specification for DWARF-2 & DWARF-3 is here:
http://dwarfstd.org/dwarf-2.0.0.pdf
http://dwarfstd.org/Dwarf3.pdf
There is a decent library for reading DWARF files here:
http://reality.sgiweb.org/davea/dwarf.html
You can either get and use that library to read your DWARF files (it reads DWARF-2 and DWARF-3) or you can take a look at the source code to puzzle out how to write your own set of libraries/functions to do the job.

You could have a look at avr-readelf in binutils. The display_debug_lines() function in binutils/dwarf.c does the job of decoding the DWARF linenumber information.
Also, as suggested above, you could use libdwarf. This does a nice job of hiding the low-level complexities of DWARF and lets you focus on getting the data out.
After setting up libdwarf with an elfdescriptor and getting a Dwarf_Debug struct, you can do the following:
Traverse all compilation units with dwarf_srclines()
use dwarf_srclines() on each cu
use dwarf_lineaddr() on each entry in the array returned from dwarf_srclines()
remember to use dwarf_dealloc() in the right places.

Related

How to print out ASCII to a separate file.

I am trying to print data using
*EL PRINT
to a separate file other that jobname.dat file.
Is there any way to do this?
PS: I know how to export the data from the odb file.
Thanks
As far as I know you can't reroute that kind of input-file keyword output request to a different file. I've listed some alternatives below:
As you mention, you can script it using the Abaqus/Python API.
You can manually print results to a file of your choosing from the Viewer.
You can access the results file for postprocessing using a Fortran or C++ program (search for ABQMAIN).
You can access results and write them to a file of your choosing during the analysis using the Fortran subroutine URDFIL.

What is the recommended way to make & load a library?

I want to make a small "library" to be used by my future maxima scripts, but I am not quite sure on how to proceed (I use wxMaxima). Maxima's documentation covers the save(), load() and loadFile() functions, yet does not provide examples. Therefore, I am not sure whether I am using the proper/best way or not. My current solution, which is based on this post, stores my library in the *.lisp format.
As a simple example, let's say that my library defines the cosSin(x) function. I open a new session and define this function as
(%i0) cosSin(x) := cos(x) * sin(x);
I then save it to a lisp file located in the /tmp/ directory.
(%i1) save("/tmp/lib.lisp");
I then open a new instance of maxima and load the library
(%i0) loadfile("/tmp/lib.lisp");
The cosSin(x) is now defined and can be called
(%i1) cosSin(%pi/4)
(%o1) 1/2
However, I noticed that a substantial number of the libraries shipped with maxima are of *.mac format: the /usr/share/maxima/5.37.2/share/ directory contains 428 *.mac files and 516 *.lisp files. Is it a better format? How would I generate such files?
More generally, what are the different ways a library can be saved and loaded? What is the recommended approach?
Usually people put the functions they need in a file name something.mac and then load("something.mac"); loads the functions into Maxima.
A file can contain any number of functions. A file can load other files, so if you have somethingA.mac and somethingB.mac, then you can have another file that just says load("somethingA.mac"); load("somethingB.mac");.
One can also create Lisp files and load them too, but it is not required to write functions in Lisp.
Unless you are specifically interested in writing Lisp functions, my advice is to write your functions in the Maxima language and put them in a file, using an ordinary text editor. Also, I recommend that you don't use save to save the functions to a file as Lisp code; just type the functions into a file, as Maxima code, with a plain text editor.
Take a look at the files in share to get a feeling for how other people have gone about it. I am looking right now at share/contrib/ggf.mac and I see it has a lengthy comment header describing its purpose -- such comments are always a good idea.
For principiants, like me,
Menu Edit:configure:Startup commands
Copy all the functions you have verified in the first box (this will write your wxmaxima-init.mac in the location indicated below)
Restart Wxmaxima.
Now you can access the functions whitout any load() command

What command line parameters do piqic and piqi accept?

The help section in the script is less than usefull I was wondering if anyone knows where the docs are for this?
Piqi author here.
Meaningful piqic erlang command-line parameters are mentioned in Piqi for Erlang User’s Manual: http://piqi.org/doc/erlang
I will put together a separate section that lists all the command-line parameters, in the meantime, you might be interested in those:
--normalize true - convert "CamelCase"-style identifiers from the original type spec into "camel-case" Erlang names
--gen-defaults - generate default constructors for the data types; they look like default_<type-name>/0 in the generated code.
-C <dir> - specify output directory for the generated code.
Command-line parameters for piqi are fairly well documented at http://piqi.org/doc/tools

how to read data from dat file?

how to read data from .dat files ?
i just tried like this memo1.lines.loadfromfile('c:\myfile.dat'); but not worked
Note : File type is binary
can any one please help me :)
#radick to show the contents of an binary file in a memo control you must encode o convert the data to valid ASCII characters, to turn it all into text. because you can not load something that is not text into a text control.
you can find a very nice sample from Peter Below in this link.
read a binary file and display the byte values as ASCII?
(source: swissdelphicenter.ch)
Use the TStream descendants from the VCL Classes unit to read binary files.
There are plenty Delphi TStream reading binary files examples you can find using Google.
--jeroen
You might look at this post as they seem to be discussing this very thing.

How to tell what types are defined in a Delphi DCU?

I have a set of compiled Delphi dcu files, without source. Is there a way to determine what types are defined inside that dcu?
To find out what's in a unit named FooUnit, type the following in your editor:
unit Test;
interface
uses FooUnit;
var
x: FooUnit.
Press Ctrl+Space at the end, and the IDE will present a list of possible completion values, which should consist primarily, if not exclusively, of type names.
You could have a look at DCU32INT, a Delphi DCU decompiler. It generates an .int file that is somehow readable but not compilable, but if you only want to determine the types defined, this could be enough.
The DCU format is undocumented, last I checked. However, there is a tool I found that might give you some basic info called DCUtoPAS. It's not very well rated on the site, but it might at least extract the types for you. There is also DCU32INT, which might help as well.
Otherwise, you might just have to open the file with a hex editor and dig around for strings.

Resources