[PATCH 3/5] Add d_main_name to dlang.c

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 3/5] Add d_main_name to dlang.c

Iain Buclaw
The main program in D is _Dmain (demangled as 'D main') not C 'main'.
So the logical entry point of the program should be set accordingly.

2014-01-09  Iain Buclaw  <[hidden email]>

        * d-lang.h (d_main_name): Add declaration.
        * d-lang.c (d_main_name): New function.
        * symtab.c (find_main_name): Add call to d_main_name.

---

dlang-p3.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/5] Add d_main_name to dlang.c

Tom Tromey
>>>>> "Iain" == Iain Buclaw <[hidden email]> writes:

Iain> The main program in D is _Dmain (demangled as 'D main') not C 'main'.
Iain> So the logical entry point of the program should be set accordingly.

Iain> 2014-01-09  Iain Buclaw  <[hidden email]>

Iain>         * d-lang.h (d_main_name): Add declaration.
Iain>         * d-lang.c (d_main_name): New function.
Iain>         * symtab.c (find_main_name): Add call to d_main_name.

This is ok.

Iain> +static const char D_MAIN[] = "D main";

If D symbols routinely demangle to have spaces in them, then I think
your users may be in for some difficulties using gdb.  Right now I think
linespecs have some hacks to let this work for C++, but I'm not sure how
readily they could be extended to the above.

If it is just the one symbol, then no big deal, there is quoting.

Tom
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/5] Add d_main_name to dlang.c

Iain Buclaw
On 9 January 2014 18:18, Tom Tromey <[hidden email]> wrote:

>>>>>> "Iain" == Iain Buclaw <[hidden email]> writes:
>
> Iain> The main program in D is _Dmain (demangled as 'D main') not C 'main'.
> Iain> So the logical entry point of the program should be set accordingly.
>
> Iain> 2014-01-09  Iain Buclaw  <[hidden email]>
>
> Iain>         * d-lang.h (d_main_name): Add declaration.
> Iain>         * d-lang.c (d_main_name): New function.
> Iain>         * symtab.c (find_main_name): Add call to d_main_name.
>
> This is ok.
>
> Iain> +static const char D_MAIN[] = "D main";
>
> If D symbols routinely demangle to have spaces in them, then I think
> your users may be in for some difficulties using gdb.  Right now I think
> linespecs have some hacks to let this work for C++, but I'm not sure how
> readily they could be extended to the above.
>
> If it is just the one symbol, then no big deal, there is quoting.
>

It's just the one symbol.  'D main' is the demangled name, _Dmain is
the mangled.  Either one works perfectly well with `start`, and when
using cgdb, it sets the start line in the correct place.
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/5] Add d_main_name to dlang.c

Iain Buclaw
On 9 January 2014 18:29, Iain Buclaw <[hidden email]> wrote:

> On 9 January 2014 18:18, Tom Tromey <[hidden email]> wrote:
>>>>>>> "Iain" == Iain Buclaw <[hidden email]> writes:
>>
>> Iain> The main program in D is _Dmain (demangled as 'D main') not C 'main'.
>> Iain> So the logical entry point of the program should be set accordingly.
>>
>> Iain> 2014-01-09  Iain Buclaw  <[hidden email]>
>>
>> Iain>         * d-lang.h (d_main_name): Add declaration.
>> Iain>         * d-lang.c (d_main_name): New function.
>> Iain>         * symtab.c (find_main_name): Add call to d_main_name.
>>
>> This is ok.
>>
>> Iain> +static const char D_MAIN[] = "D main";
>>
>> If D symbols routinely demangle to have spaces in them, then I think
>> your users may be in for some difficulties using gdb.  Right now I think
>> linespecs have some hacks to let this work for C++, but I'm not sure how
>> readily they could be extended to the above.
>>
>> If it is just the one symbol, then no big deal, there is quoting.
>>
>
> It's just the one symbol.  'D main' is the demangled name, _Dmain is
> the mangled.  Either one works perfectly well with `start`, and when
> using cgdb, it sets the start line in the correct place.

So would you prefer that _Dmain were used here?
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/5] Add d_main_name to dlang.c

Tom Tromey
>>>>> "Iain" == Iain Buclaw <[hidden email]> writes:

Iain> So would you prefer that _Dmain were used here?

It's fine as-is.

In that note I was actually asking about the generic problem of
specifying demangled D names to the linespec parser.  But since spaces
don't generally appear there, there's no big issue.  This is kind of
tangential to the patch at hand, just seeing that space made me wonder.

Tom
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/5] Add d_main_name to dlang.c

Iain Buclaw
On 10 January 2014 18:57, Tom Tromey <[hidden email]> wrote:

>>>>>> "Iain" == Iain Buclaw <[hidden email]> writes:
>
> Iain> So would you prefer that _Dmain were used here?
>
> It's fine as-is.
>
> In that note I was actually asking about the generic problem of
> specifying demangled D names to the linespec parser.  But since spaces
> don't generally appear there, there's no big issue.  This is kind of
> tangential to the patch at hand, just seeing that space made me wonder.
>

Currently all demangled symbols have to be 'quoted' because they are
in the format foo.bar.baz.  Incidentally, I was just looking into
writing a separate expression parser for D (d-exp.y).  I don't suppose
you'd know off the bat whether - if written properly - it would be
able to handle D demangled symbols without the need to quote them?

Thanks
Iain.
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/5] Add d_main_name to dlang.c

Tom Tromey
>>>>> "Iain" == Iain Buclaw <[hidden email]> writes:

Iain> Currently all demangled symbols have to be 'quoted' because they are
Iain> in the format foo.bar.baz.  Incidentally, I was just looking into
Iain> writing a separate expression parser for D (d-exp.y).  I don't suppose
Iain> you'd know off the bat whether - if written properly - it would be
Iain> able to handle D demangled symbols without the need to quote them?

I just replied about this on the D debugger list :)

"break" and some other commands use "linespecs", not expressions.
(Well, in addition to expressions, as you can always "break *EXPR".)
See gdb/linespec.c.

linespec already handles "." as a separator for Java, so it should be
possible to make it work for D.  I don't recall the details; this code's
gone through a lot in the past couple of years (for the better I assure
you :-)

Tom
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/5] Add d_main_name to dlang.c

Iain Buclaw
In reply to this post by Tom Tromey
On 9 January 2014 18:18, Tom Tromey <[hidden email]> wrote:

>>>>>> "Iain" == Iain Buclaw <[hidden email]> writes:
>
> Iain> The main program in D is _Dmain (demangled as 'D main') not C 'main'.
> Iain> So the logical entry point of the program should be set accordingly.
>
> Iain> 2014-01-09  Iain Buclaw  <[hidden email]>
>
> Iain>         * d-lang.h (d_main_name): Add declaration.
> Iain>         * d-lang.c (d_main_name): New function.
> Iain>         * symtab.c (find_main_name): Add call to d_main_name.
>
> This is ok.
>

FYI, this has been amended slightly for the recent change to set_main_name.

dlang-p3.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/5] Add d_main_name to dlang.c

Iain Buclaw
On 18 January 2014 17:09, Iain Buclaw <[hidden email]> wrote:

> On 9 January 2014 18:18, Tom Tromey <[hidden email]> wrote:
>>>>>>> "Iain" == Iain Buclaw <[hidden email]> writes:
>>
>> Iain> The main program in D is _Dmain (demangled as 'D main') not C 'main'.
>> Iain> So the logical entry point of the program should be set accordingly.
>>
>> Iain> 2014-01-09  Iain Buclaw  <[hidden email]>
>>
>> Iain>         * d-lang.h (d_main_name): Add declaration.
>> Iain>         * d-lang.c (d_main_name): New function.
>> Iain>         * symtab.c (find_main_name): Add call to d_main_name.
>>
>> This is ok.
>>
>
>
> FYI, this has been amended slightly for the recent change to set_main_name.

And committed.

Regards
Iain