perl script for GNAT tracebacks 
Author Message
 perl script for GNAT tracebacks

The following perl code produces trace backs under my system running
Solaris for programs built with GNAT which raise an exception.  It
might work with other systems.  It might even work on your system.

Assuming you call this program "gnatbt" (and assuming
you have perl and assuming that you've accounted for its
location etc ...) you would run it as follows:

   Step 1) my_program my_arguments ...

   raise SOME_CONSTRAINT_ERROR

   Step 2) gnatbt my_program my_arguments ...

   get an ugly gdb traceback with line numbers.

Enjoy.
Thanks to the folks at ACT for help with the GDB commands.

#!/usr/local/bin/perl
#  

if ($#ARGV < 0) {
   print "usage: gnatbt (program) [command line] \n";
   exit 1;

Quote:
}

else {
    $program = $ARGV[0];

Quote:
}

# read the command line

$command_line = "";
$first = 1;

    if (not $first) {
        $command_line = $command_line . " " . $parameter;}
    $first = 0;}

# make the GDB script

open (GDB_FILE, ">" . $program . '.gdb');
print GDB_FILE ' set args ' . $command_line . "\n";
print GDB_FILE ' handle SIGSEGV nostop ' . "\n";
print GDB_FILE ' break __gnat_raise'. "\n";
print GDB_FILE ' commands '. "\n";
print GDB_FILE ' backtrace'. "\n";
print GDB_FILE ' continue'. "\n";
print GDB_FILE ' end'. "\n";
print GDB_FILE ' run'. "\n";
close (GDB_FILE);

# pipe the GDB output to a file

system ("gdb -batch -x $program.gdb $program > $program.output 2>&1");

# count the number of exceptions

open (GDB_OUTPUT, "<" . $program . '.output');
$count=0;
while (<GDB_OUTPUT>) {
    if (/Breakpoint/) {$count = $count + 1;};

Quote:
}

close (GDB_OUTPUT);

# print last traceback

open (GDB_OUTPUT, "<" . $program . '.output');
while (<GDB_OUTPUT>) {
    if (/Breakpoint/) {$count = $count - 1;};
    if ($count == 0) {print};

Quote:
}

close (GDB_OUTPUT);

--



Sun, 19 Dec 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Traceback on Gnat/Linux

2. Bug in GNAT.Traceback.Symbolic?

3. How to get a traceback in Gnat 3.14p

4. Problem using Gnat.Traceback.Symbolic.Symbolic_Traceback()

5. GNAT.Traceback is back...

6. Tracebacks, GNAT

7. using package GNAT.Traceback

8. GNAT/Ada Traceback Information?

9. GNAT exception traceback

10. GNAT : Exception traceback

11. Perl CGI Script Invoking Expect Script

12. Does anyone have a perl script (or other method) to convert scripts fro

 

 
Powered by phpBB® Forum Software