Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
February 06, 2012 linux linenumbers in stacktraces and druntime/phobos debug builds.. | ||||
---|---|---|---|---|
| ||||
I get an segfault in druntime, but have no idea where to start looking. _D4core7runtime18runModuleUnitTestsUZb19unittestSegvHandlerUiPS4core3sys5posix6signal9siginfo_tPvZv+0x3c I cannot seem to find a way to enable line numbers in traces (adding -g adds line numbers in win, but not linux), and I cannot find any debug build of libphobos2.a - is it included? what is it called? PS: using dmd 2.057 on kubuntu x64 using the deb package from digitalmars.com |
February 06, 2012 Re: linux linenumbers in stacktraces and druntime/phobos debug builds.. | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | On Monday, February 06, 2012 21:36:38 simendsjo wrote: > I get an segfault in druntime, but have no idea where to start looking. _D4core7runtime18runModuleUnitTestsUZb19unittestSegvHandlerUiPS4core3sys5pos ix6signal9siginfo_tPvZv+0x3c > > I cannot seem to find a way to enable line numbers in traces (adding -g adds line numbers in win, but not linux), and I cannot find any debug build of libphobos2.a - is it included? what is it called? > > PS: using dmd 2.057 on kubuntu x64 using the deb package from digitalmars.com Posix' backtrace facilities do not provide a way to get the file names or line numbers - just the addresses and symbol names (though the fact that module names and file names are normally the same makes it so that the file name is essentially in the symbol name in D). Now, according to this answer on stackoverflow http://stackoverflow.com/questions/3151779/how-its-better-to-invoke-gdb-from- program-to-print-its-stacktrace/4611112#4611112 it looks like it's possible to use addr2line to do the job under at least some circumstances. So, it may be possible to add it to druntime, but there's no way for you to just enable it. Now, the stack traces _do_ give you the addresses, so you could use addr2line yourself to get the file and line numbers for at least some of the stack trace (some lines will probably yield ??:0). You _will_ have to compile with -g for that to work though (otherwise _all_ lines will yield ??:0). - Jonathan M Davis |
February 06, 2012 Re: linux linenumbers in stacktraces and druntime/phobos debug builds.. | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | On Monday, 6 February 2012 at 20:36:39 UTC, simendsjo wrote:
> I get an segfault in druntime, but have no idea where to start looking.
> _D4core7runtime18runModuleUnitTestsUZb19unittestSegvHandlerUiPS4core3sys5posix6signal9siginfo_tPvZv+0x3c
>
> I cannot seem to find a way to enable line numbers in traces (adding -g adds line numbers in win, but not linux), and I cannot find any debug build of libphobos2.a - is it included? what is it called?
>
> PS: using dmd 2.057 on kubuntu x64 using the deb package from digitalmars.com
If you have a segmentation fault then you will need to compile with -g, turn on core dumps and use gdb.
$ ulimit -c unlimited
$ ./test
$ gdb ./test core
You will be provided with file and line number, well the file may just be a module name don't remember.
Also based on that mangled string it looks like you are running the Druntime unittests. I've never used the above to get at Unittest segfaults...
|
February 08, 2012 Re: linux linenumbers in stacktraces and druntime/phobos debug builds.. | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | I actually ran into this myself while working on a pet game project, and here's what I do.
First, let's start with a simple program that segfaults due to a null pointer.
// File seg.d
class Dummy {
int a;
}
void main() {
Dummy d;
d.a = 3;
}
You compile and run the program with expected results.
$ dmd seg.d
$ ./seg
Segmentation fault
If you have an older version of gdb, you should compile your program to include C compatible symbols.
$ dmd -gc seg.d
Now run your program through gdb.
$ gdb seg
(gdb) run
Starting program: /home/vnayar/projects/Demo/seg
[Thread debugging using libthread_db enabled]
Program received signal SIGSEGV, Segmentation fault.
_Dmain () at seg.d:7
7 d.a = 3;
And now you're good to go.
- Vijay
On Mon, 6 Feb 2012, simendsjo wrote:
> I get an segfault in druntime, but have no idea where to start looking.
> _D4core7runtime18runModuleUnitTestsUZb19unittestSegvHandlerUiPS4core3sys5posix6signal9siginfo_tPvZv+0x3c
>
> I cannot seem to find a way to enable line numbers in traces (adding -g adds line numbers in win, but not linux), and I cannot find any debug build of libphobos2.a - is it included? what is it called?
>
> PS: using dmd 2.057 on kubuntu x64 using the deb package from digitalmars.com
>
|
February 09, 2012 Re: linux linenumbers in stacktraces and druntime/phobos debug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vijay Nayar | Vijay Nayar:
> First, let's start with a simple program that segfaults due to a null pointer.
>
> // File seg.d
> class Dummy {
> int a;
> }
>
> void main() {
> Dummy d;
> d.a = 3;
> }
>
> You compile and run the program with expected results.
>
> $ dmd seg.d
> $ ./seg
> Segmentation fault
Also try to compile it with -O :-)
Bye,
bearophile
|
Copyright © 1999-2021 by the D Language Foundation