| Thread overview | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
July 13, 2010 Debugging | ||||
|---|---|---|---|---|
| ||||
I have jumped back onto the D2 band-wagon after a long absence, read Andrei's book, and am having a great time cutting heaps of D code. My increase in productivity and happiness when compared to working in C++ is enormous.
Bug thumbs up to everyone involved with D2, Phobos and the book.
One area I am having a bit of trouble with is debugging. Can anyone help me out with how to debug a D2 program in Linux? Currently I am reduced to printing out heaps of debug text.
Specifically:
Stack Trace:
------------
I can't get the D2 stack-trace to work properly. All I get is something like this, which isn't helpful:
Segmentation fault
The code I used to generate this was:
import std.stdio;
import std.file;
void foo(File file) {
file.flush;
}
void main(string[] args) {
File file;
foo(file);
}
Is stack-trace support broken, or do I have to do something to enable it?
GDB:
----
What is the status of D support in GDB? The last post I saw was back in April. It is currently hard work to debug with gdb when it doesn't understand D name mangling.
Profiling:
----------
How do I profile a D2 program? When I try -profile in dmd, the resultant executable crashes with a segfault when I try to run it. When I try sysprof, I get a handful of mangled names, and no call graph.
| ||||
July 13, 2010 Re: Debugging | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Graham St Jack | Graham St Jack:
> How do I profile a D2 program? When I try -profile in dmd, the resultant executable crashes with a segfault when I try to run it.
Are you able to produce a small test case of this bug?
Bye,
bearophile
| |||
July 13, 2010 Re: Debugging | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Graham St Jack | On Tue, 13 Jul 2010 02:26:22 -0400, Graham St Jack <Graham.StJack@internode.on.net> wrote: > I have jumped back onto the D2 band-wagon after a long absence, read > Andrei's book, and am having a great time cutting heaps of D code. My > increase in productivity and happiness when compared to working in C++ is > enormous. > > Bug thumbs up to everyone involved with D2, Phobos and the book. > > One area I am having a bit of trouble with is debugging. Can anyone help > me out with how to debug a D2 program in Linux? Currently I am reduced to > printing out heaps of debug text. > > Specifically: > > Stack Trace: > ------------ > > I can't get the D2 stack-trace to work properly. All I get is something > like this, which isn't helpful: > > Segmentation fault > > The code I used to generate this was: > import std.stdio; > import std.file; > void foo(File file) { > file.flush; > } > void main(string[] args) { > File file; > foo(file); > } > Is stack-trace support broken, or do I have to do something to enable it? Seg faults do not generate stack traces in Linux/MacOS. This is because a segmentation fault is generated by a signal, and it's unsafe to throw exceptions from signals. I believe seg faults can generate exceptions in Windows, but I'm not sure. Your best bet is to get a debugger working, and it will halt on the signal. As I understand it, a lot of good work was done recently on dmd (can't remember who did it) to get it working better with gdb. -Steve | |||
July 13, 2010 Re: Debugging | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Graham St Jack | On 07/13/2010 01:26 AM, Graham St Jack wrote: > I have jumped back onto the D2 band-wagon after a long absence, read > Andrei's book, and am having a great time cutting heaps of D code. My > increase in productivity and happiness when compared to working in C++ is > enormous. > > Bug thumbs up to everyone involved with D2, Phobos and the book. [snip] Thanks. Bug thumbs up? Clearly you had debugging on your mind :o). Check http://www.zerobugs.org/. Andrei | |||
July 13, 2010 Re: Debugging | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 07/13/2010 10:34 AM, Andrei Alexandrescu wrote: > On 07/13/2010 01:26 AM, Graham St Jack wrote: >> I have jumped back onto the D2 band-wagon after a long absence, read >> Andrei's book, and am having a great time cutting heaps of D code. My >> increase in productivity and happiness when compared to working in C++ is >> enormous. >> >> Bug thumbs up to everyone involved with D2, Phobos and the book. > [snip] > > Thanks. Bug thumbs up? Clearly you had debugging on your mind :o). > > Check http://www.zerobugs.org/. > > > Andrei I guess the more recent site is at http://www.zero-bugs.com/2.0/product_intro.html Andrei | |||
July 13, 2010 Re: Debugging | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Tue, 13 Jul 2010 11:35:55 -0400, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote: > On 07/13/2010 10:34 AM, Andrei Alexandrescu wrote: >> On 07/13/2010 01:26 AM, Graham St Jack wrote: >>> I have jumped back onto the D2 band-wagon after a long absence, read >>> Andrei's book, and am having a great time cutting heaps of D code. My >>> increase in productivity and happiness when compared to working in C++ is >>> enormous. >>> >>> Bug thumbs up to everyone involved with D2, Phobos and the book. >> [snip] >> >> Thanks. Bug thumbs up? Clearly you had debugging on your mind :o). >> >> Check http://www.zerobugs.org/. >> >> >> Andrei > > I guess the more recent site is at http://www.zero-bugs.com/2.0/product_intro.html Does that support D? The faq says: "I have started some preliminary work to support Walter Bright's D Programming Language, and a D demangler has been contributed by the D community. However, this work is in an experimental stage." -Steve | |||
July 13, 2010 Re: Debugging | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | Steven Schveighoffer Wrote:
> On Tue, 13 Jul 2010 11:35:55 -0400, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:
>
> > On 07/13/2010 10:34 AM, Andrei Alexandrescu wrote:
> >> On 07/13/2010 01:26 AM, Graham St Jack wrote:
> >>> I have jumped back onto the D2 band-wagon after a long absence, read
> >>> Andrei's book, and am having a great time cutting heaps of D code. My
> >>> increase in productivity and happiness when compared to working in C++
> >>> is
> >>> enormous.
> >>>
> >>> Bug thumbs up to everyone involved with D2, Phobos and the book.
> >> [snip]
> >>
> >> Thanks. Bug thumbs up? Clearly you had debugging on your mind :o).
> >>
> >> Check http://www.zerobugs.org/.
> >>
> >>
> >> Andrei
> >
> > I guess the more recent site is at http://www.zero-bugs.com/2.0/product_intro.html
>
> Does that support D? The faq says:
>
> "I have started some preliminary work to support Walter Bright's D
> Programming Language, and a D demangler has been contributed by the D
> community. However, this work is in an experimental stage."
>
> -Steve
I never got it to work. It's very picky about the environment setup.
| |||
July 13, 2010 Re: Debugging | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Graham St Jack | Graham St Jack, el 13 de julio a las 06:26 me escribiste: > GDB: > ---- > > What is the status of D support in GDB? The last post I saw was back in April. It is currently hard work to debug with gdb when it doesn't understand D name mangling. The patch was accepted a while ago and the next GDB version will heve them (you can try CVS's GDB if you need it now). I'm not sure if it support D2 new stuff though. > Profiling: > ---------- > > How do I profile a D2 program? When I try -profile in dmd, the resultant executable crashes with a segfault when I try to run it. When I try sysprof, I get a handful of mangled names, and no call graph. Same here, I use valgrind's callgrind + kcachegrind, is slooooow, but very nice. -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- No debemos temer a la muerte, porque es la mejor recompensa de la vida. -- Ren & Stimpy | |||
July 13, 2010 Re: Debugging | ||||
|---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Tue, 13 Jul 2010 03:55:08 -0400, bearophile wrote:
> Graham St Jack:
>> How do I profile a D2 program? When I try -profile in dmd, the resultant executable crashes with a segfault when I try to run it.
>
> Are you able to produce a small test case of this bug?
>
> Bye,
> bearophile
Small test cases don't crash. I will spend a bit of time experimenting with my way-too-big test case to find out why it crashes when run after being compiled with -profile, and post my results here.
One thing I noticed was that the trace.log file doesn't demangle the names properly either.
| |||
July 13, 2010 Re: Debugging | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Tue, 13 Jul 2010 10:34:41 -0500, Andrei Alexandrescu wrote:
> On 07/13/2010 01:26 AM, Graham St Jack wrote:
>> I have jumped back onto the D2 band-wagon after a long absence, read Andrei's book, and am having a great time cutting heaps of D code. My increase in productivity and happiness when compared to working in C++ is enormous.
>>
>> Bug thumbs up to everyone involved with D2, Phobos and the book.
> [snip]
>
> Thanks. Bug thumbs up? Clearly you had debugging on your mind :o).
>
> Check http://www.zerobugs.org/.
>
>
> Andrei
Freudian slip...
I love the book by the way - I couldn't put it down. D is totally awesome now, and there were heaps of cool new features that I didn't know about.
Thanks again.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply