On Wed, Oct 28, 2009 at 09:59:45AM -0700, Peter LaDow wrote:
> I've been doing some more digging into this problem.  I think perhaps
> there is an issue with my build of GHDL.  I've been setting
> breakpoints and single stepping through the code trying to find a
> cause.  I did find one things that seemed odd.
> 
> First, I've been debugging the pure VHDL simulation.  I set a
> breakpoint in main, and looked at the stack to see if things made
> sense.  For example

If you're using 32 bits linux, can you test with the pre-built version
of ghdl ?

> (gdb) b 24
> Breakpoint 1 at 0x80a0e5a: file
> ../../../gcc-4.3.4/gcc/vhdl/grt/main.adb, line 24.
> (gdb) r
> Starting program:
> /home/pete/ghdl-pladow/fpga_stamp/fpga_stamp_m0/test/fpga_stamp_t0
> 
> Breakpoint 1, main (argc=1, argv=(system.address) 0xbf953d94)
>     at ../../../gcc-4.3.4/gcc/vhdl/grt/main.adb:24
> 24         return Ghdl_Main (Argc, Argv);
> 
> Note that argc and argv look fine.  But if I let it run until the error, I 
> get:
> 
> (gdb) c
> Program received signal SIGSEGV, Segmentation fault.
> 0xec835356 in ?? ()
> (gdb) bt
> [...snip...]
> #8  0x080a0e66 in main (argc=Cannot access memory at address
> 0xe58955c3) at ../../../gcc-4.3.4/gcc/vhdl/grt/main.adb:24
> (gdb) frame 8
> #8  0x080a0e66 in main (argc=Cannot access memory at address
> 0xe58955c3) at ../../../gcc-4.3.4/gcc/vhdl/grt/main.adb:24
> 24         return Ghdl_Main (Argc, Argv);
> (gdb) p Argc
> Cannot access memory at address 0xe58955c3
> (gdb) p Argv
> Cannot access memory at address 0xe58955c7
> 
> Note that argc is completely trashed.  And argv as well.  This hints
> at stack corruption.  So, I started single stepping through the code
> to try and find the problem.  I stepped and looked for when argc and
> argv became trashed.  Here's the call that did it:

Not sure.  GHDL switches stack and that may confuse gdb.

> (gdb) s
> 48         Grt_Init;
> (gdb) bt
> #0  ghdl_main (argc=1, argv=(system.address) 0xbf981774) at
> /home/pete/Download/gcc-4.3.4/gcc/vhdl/grt/ghdl_main.adb:48
> #1  0x080a0e66 in main (argc=1, argv=(system.address) 0xbf981774) at
> ../../../gcc-4.3.4/gcc/vhdl/grt/main.adb:24
> (gdb) s
> 49         Grt.Main.Run;
> (gdb) bt
> #0  ghdl_main (argc=1, argv=(system.address) 0x7a51e8) at
> /home/pete/Download/gcc-4.3.4/gcc/vhdl/grt/ghdl_main.adb:49
> #1  0x080a0e66 in main (argc=8024052, argv=(system.address) 0x7a51e8)
> at ../../../gcc-4.3.4/gcc/vhdl/grt/main.adb:24
> 
> The call to Grt_Init seems to trash main's argc and argv.  Now, I've
> been digging around trying to find the code for Grt_Init.  The only
> thing I find is at the top of ghdl_main.adb:
> 
>    --  Grt_Init corresponds to the 'adainit' subprogram for grt.
>    procedure Grt_Init;
>    pragma Import (C, Grt_Init, "grt_init");
> 
> Now, it looks like grt_init is generated (I found it in the build
> directory).  But I can't single step into the code.  And without line
> information I can't see where things are going wrong.

Well, this is a very simple file.  You can debug it provided -g is used
during compilation.

> Now, considering this is a generated file from my build, and the
> problem appears to be here, I'm thinking there is definitely something
> wrong with my build.  I've attached the generated grt_init code
> (run-bind.adb) for your perusal.

You should give a try with the ghdl binaries.

Tristan.

_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss

Reply via email to