www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - I have a patch to let lldb demangle D symbols ; help welcome to

reply Timothee Cour <thelastmammoth gmail.com> writes:
https://github.com/llvm-mirror/lldb/pull/3
+
https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d


on OSX, it works great except when encountering large symbols which
cause segfault when GC does a collection (triggered inside
core.demangle.demangle);
Help is welcome to improve that (or more generally to improve D
support in lldb, which I started in
https://github.com/llvm-mirror/lldb/pull/3)
NOTE: lldb doesn't accept github PR's but easier to work with PR's for
whoever wants to help on tha in the meantime
Feb 26 2018
next sibling parent reply timotheecour <timothee.cour2 gmail.com> writes:
On Tuesday, 27 February 2018 at 05:28:41 UTC, Timothee Cour wrote:
 https://github.com/llvm-mirror/lldb/pull/3
 +
 https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d


 on OSX, it works great except when encountering large symbols 
 which
 cause segfault when GC does a collection (triggered inside
 core.demangle.demangle);
 Help is welcome to improve that (or more generally to improve D
 support in lldb, which I started in
 https://github.com/llvm-mirror/lldb/pull/3)
 NOTE: lldb doesn't accept github PR's but easier to work with 
 PR's for
 whoever wants to help on tha in the meantime
Specifically, the issue I'm facing is: https://github.com/timotheecour/dtools/issues/2 (a crash occurs when _d_arraysetlengthiT is called) any help would be greatly appreciated
Feb 27 2018
parent reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
On Tuesday, 27 February 2018 at 11:23:02 UTC, timotheecour wrote:
 On Tuesday, 27 February 2018 at 05:28:41 UTC, Timothee Cour 
 wrote:
 https://github.com/llvm-mirror/lldb/pull/3
 +
 https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d


 on OSX, it works great except when encountering large symbols 
 which
 cause segfault when GC does a collection (triggered inside
 core.demangle.demangle);
 Help is welcome to improve that (or more generally to improve D
 support in lldb, which I started in
 https://github.com/llvm-mirror/lldb/pull/3)
 NOTE: lldb doesn't accept github PR's but easier to work with 
 PR's for
 whoever wants to help on tha in the meantime
Specifically, the issue I'm facing is: https://github.com/timotheecour/dtools/issues/2 (a crash occurs when _d_arraysetlengthiT is called) any help would be greatly appreciated
Thanks for working on this. I'll try to look into this in the next few days. (If you have further progress on this please provide an update here).
Mar 01 2018
parent reply Timothee Cour <thelastmammoth gmail.com> writes:
yes, I've fixed the issue with crashes on large symbols using a
patched `demangle` ; will update code soon; but feel free to take a
look at lldb side of things




On Thu, Mar 1, 2018 at 12:23 PM, Luís Marques via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Tuesday, 27 February 2018 at 11:23:02 UTC, timotheecour wrote:
 On Tuesday, 27 February 2018 at 05:28:41 UTC, Timothee Cour wrote:
 https://github.com/llvm-mirror/lldb/pull/3
 +
 https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d


 on OSX, it works great except when encountering large symbols which
 cause segfault when GC does a collection (triggered inside
 core.demangle.demangle);
 Help is welcome to improve that (or more generally to improve D
 support in lldb, which I started in
 https://github.com/llvm-mirror/lldb/pull/3)
 NOTE: lldb doesn't accept github PR's but easier to work with PR's for
 whoever wants to help on tha in the meantime
Specifically, the issue I'm facing is: https://github.com/timotheecour/dtools/issues/2 (a crash occurs when _d_arraysetlengthiT is called) any help would be greatly appreciated
Thanks for working on this. I'll try to look into this in the next few days. (If you have further progress on this please provide an update here).
Mar 01 2018
parent reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
On Friday, 2 March 2018 at 00:17:13 UTC, Timothee Cour wrote:
 yes, I've fixed the issue with crashes on large symbols using a 
 patched `demangle` ; will update code soon; but feel free to 
 take a look at lldb side of things
What version of LLVM did you base it on? On my LLVM fork for RISC-V and MSP430 work it doesn't build (no llvm/Support/DJB.h) and on the latest stable, 5.0.1, cmake fails to configure (Unknown CMake command "add_llvm_install_targets").
Mar 06 2018
parent reply Johan Engelen <j j.nl> writes:
On Tuesday, 6 March 2018 at 18:19:13 UTC, Luís Marques wrote:
 On my LLVM fork for RISC-V and MSP430 work it doesn't build (no 
 llvm/Support/DJB.h) and on the latest stable, 5.0.1, cmake 
 fails to configure (Unknown CMake command 
 "add_llvm_install_targets").
LLDB and LLVM need to be version synchronized. Did you checkout LLVM and LLDB both from their respective same-named release branches? -Johan
Mar 06 2018
parent reply Johan Engelen <j j.nl> writes:
On Tuesday, 6 March 2018 at 20:25:10 UTC, Johan Engelen wrote:
 On Tuesday, 6 March 2018 at 18:19:13 UTC, Luís Marques wrote:
 On my LLVM fork for RISC-V and MSP430 work it doesn't build 
 (no llvm/Support/DJB.h) and on the latest stable, 5.0.1, cmake 
 fails to configure (Unknown CMake command 
 "add_llvm_install_targets").
LLDB and LLVM need to be version synchronized. Did you checkout LLVM and LLDB both from their respective same-named release branches?
I'm pretty sure Timothee based his patch onto LLDB/LLVM trunk. -Johan
Mar 06 2018
parent Timothee Cour <thelastmammoth gmail.com> writes:
 I'm pretty sure Timothee based his patch onto LLDB/LLVM trunk.
indeed, see instructions here: https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d
 Seems like they prefer a shared library and not rewriting it in C++ [1].
indeed, I would not support something that requires rewriting demangle in C++ for obvious reasons (lots of useless work, gets out of sync etc).
 BTW, there's also GNU libiberty, bart of binutils, which Iain claims have
better support for demangling D symbols than core.demangler.
IIRC he wrote that, so we'd need an unbiased opinion :) But more importantly, libiberty is not up to date with latest features in core.demangle (eg back references etc). Also, I'd like to know in what way it'd be better. I had to make some small modifications to core.demangle to avoid https://github.com/timotheecour/dtools/issues/2 ; it works, but a bit ugly (see https://github.com/timotheecour/dtools/issues/2 for discussion) On Tue, Mar 6, 2018 at 12:26 PM, Johan Engelen via Digitalmars-d <digitalmars-d puremagic.com> wrote:
 On Tuesday, 6 March 2018 at 20:25:10 UTC, Johan Engelen wrote:
 On Tuesday, 6 March 2018 at 18:19:13 UTC, Luís Marques wrote:
 On my LLVM fork for RISC-V and MSP430 work it doesn't build (no
 llvm/Support/DJB.h) and on the latest stable, 5.0.1, cmake fails to
 configure (Unknown CMake command "add_llvm_install_targets").
LLDB and LLVM need to be version synchronized. Did you checkout LLVM and LLDB both from their respective same-named release branches?
I'm pretty sure Timothee based his patch onto LLDB/LLVM trunk. -Johan
Mar 08 2018
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On Tuesday, 27 February 2018 at 05:28:41 UTC, Timothee Cour wrote:
 https://github.com/llvm-mirror/lldb/pull/3
 +
 https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d


 on OSX, it works great except when encountering large symbols 
 which
 cause segfault when GC does a collection (triggered inside
 core.demangle.demangle);
 Help is welcome to improve that (or more generally to improve D
 support in lldb, which I started in
 https://github.com/llvm-mirror/lldb/pull/3)
 NOTE: lldb doesn't accept github PR's but easier to work with 
 PR's for
 whoever wants to help on tha in the meantime
This is great work. Keep in mind that DMD does not support dynamic libraries on macOS. -- /Jacob Carlborg
Mar 01 2018
prev sibling next sibling parent reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
On Tuesday, 27 February 2018 at 05:28:41 UTC, Timothee Cour wrote:
 https://github.com/llvm-mirror/lldb/pull/3
 +
 https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d
Ok, I started looking into this now. I hadn't realized that you were opening an external library. I'm not sure the LLDB developers are going to want to merge something like that, have you asked? Would you consider adding C++ code for the demangling itself instead?
Mar 05 2018
parent Jacob Carlborg <doob me.com> writes:
On Monday, 5 March 2018 at 20:03:39 UTC, Luís Marques wrote:
 On Tuesday, 27 February 2018 at 05:28:41 UTC, Timothee Cour 
 wrote:
 https://github.com/llvm-mirror/lldb/pull/3
 +
 https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d
Ok, I started looking into this now. I hadn't realized that you were opening an external library. I'm not sure the LLDB developers are going to want to merge something like that, have you asked? Would you consider adding C++ code for the demangling itself instead?
Seems like they prefer a shared library and not rewriting it in C++ [1]. BTW, there's also GNU libiberty, bart of binutils, which Iain claims have better support for demangling D symbols than core.demangler. [1] http://lists.llvm.org/pipermail/lldb-dev/2018-January/013199.html -- /Jacob Carlborg
Mar 05 2018
prev sibling next sibling parent reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
On Tuesday, 27 February 2018 at 05:28:41 UTC, Timothee Cour wrote:
 https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d
dtools seems to rely on the old import visibility behavior and doesn't compile with a recent D compiler. For instance: // functional.d: import std.algorithm:sort,uniq,walkLength; Error: module std.algorithm import 'walkLength' not found
Mar 09 2018
parent Timothee Cour <thelastmammoth gmail.com> writes:
updated build instructions, see
https://github.com/timotheecour/dtools/commit/8597923dd4ed7691f717b5e1bdbbf2ee66961ef5

On Fri, Mar 9, 2018 at 9:33 AM, Luís Marques via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Tuesday, 27 February 2018 at 05:28:41 UTC, Timothee Cour wrote:
 https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d
dtools seems to rely on the old import visibility behavior and doesn't compile with a recent D compiler. For instance: // functional.d: import std.algorithm:sort,uniq,walkLength; Error: module std.algorithm import 'walkLength' not found
Mar 09 2018
prev sibling parent reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
On Tuesday, 27 February 2018 at 05:28:41 UTC, Timothee Cour wrote:
 https://github.com/llvm-mirror/lldb/pull/3
 +
 https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d
I put a writeln in lldbd_demangle and I see it's demangling about two pagefuls of symbols, but the backtrace still shows mangled names. The mangled names lack the initial underscore, maybe that's related? breakpoint 2.1 test`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv + 40 test`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 32 test`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 139 test`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 32
Mar 12 2018
parent reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
On Monday, 12 March 2018 at 14:19:03 UTC, Luís Marques wrote:
 On Tuesday, 27 February 2018 at 05:28:41 UTC, Timothee Cour 
 wrote:
 https://github.com/llvm-mirror/lldb/pull/3
 +
 https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d
(BTW, if I commented out the plugin path setting I would get an assertion failure. Just FYI if that helps with the code review.)
Mar 12 2018
parent reply Timothee Cour <thelastmammoth gmail.com> writes:
  The mangled names lack the initial underscore, maybe that's related?
quite likely, try to compile with ldc or with latest dmd (2.079, which fixed underscores on OSX) so that demangling works. I just tried with dmd 2.078 and it indeed doesn't demangle (as expected) On Mon, Mar 12, 2018 at 7:21 AM, Luís Marques via Digitalmars-d <digitalmars-d puremagic.com> wrote:
 On Monday, 12 March 2018 at 14:19:03 UTC, Luís Marques wrote:
 On Tuesday, 27 February 2018 at 05:28:41 UTC, Timothee Cour wrote:
 https://github.com/llvm-mirror/lldb/pull/3
 +
 https://github.com/timotheecour/dtools/blob/master/dtools/lldbdplugin.d
(BTW, if I commented out the plugin path setting I would get an assertion failure. Just FYI if that helps with the code review.)
Mar 12 2018
parent reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
On Monday, 12 March 2018 at 23:03:33 UTC, Timothee Cour wrote:
 quite likely, try to compile with ldc or with latest dmd 
 (2.079, which
 fixed underscores on OSX) so that demangling works. I just 
 tried with
 dmd 2.078 and it indeed doesn't demangle (as expected)
Yeah, that works. I'll be trying it more thoroughly and report any issues.
Mar 13 2018
parent reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
On Tuesday, 13 March 2018 at 14:00:39 UTC, Luís Marques wrote:
 On Monday, 12 March 2018 at 23:03:33 UTC, Timothee Cour wrote:
 Yeah, that works. I'll be trying it more thoroughly and report 
 any issues.
Even with DMD 2.079 the frame locals don't show up... LDC FTW!
Mar 13 2018
next sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
 (BTW, if I commented out the plugin path setting I would get an assertion
failure. Just FYI if that helps with the code review.)
fixed ; thanks for reporting! On Tue, Mar 13, 2018 at 9:29 AM, Luís Marques via Digitalmars-d <digitalmars-d puremagic.com> wrote:
 On Tuesday, 13 March 2018 at 14:00:39 UTC, Luís Marques wrote:
 On Monday, 12 March 2018 at 23:03:33 UTC, Timothee Cour wrote:
 Yeah, that works. I'll be trying it more thoroughly and report any issues.
Even with DMD 2.079 the frame locals don't show up... LDC FTW!
Mar 14 2018
prev sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
 Even with DMD 2.079 the frame locals don't show up... LDC FTW!
confirmed, `fr v` shows frame locals for a binary built with ldc but not dmd (independent of this PR though :) ) => just submitted https://issues.dlang.org/show_bug.cgi?id=18612 On Tue, Mar 13, 2018 at 9:29 AM, Luís Marques via Digitalmars-d <digitalmars-d puremagic.com> wrote:
 On Tuesday, 13 March 2018 at 14:00:39 UTC, Luís Marques wrote:
 On Monday, 12 March 2018 at 23:03:33 UTC, Timothee Cour wrote:
 Yeah, that works. I'll be trying it more thoroughly and report any issues.
Even with DMD 2.079 the frame locals don't show up... LDC FTW!
Mar 14 2018