Re: GDC Explorer - an online disassembler for D

2018-05-20 Thread IntegratedDimensions via Digitalmars-d
On Friday, 21 September 2012 at 03:46:12 UTC, Andrei Alexandrescu 
wrote:
I've met Matt Goldbolt, the author of the GCC Explorer at 
http://gcc.godbolt.org - a very handy online disassembler for 
GCC.


We got to talk a bit about D and he hacked together support for 
D by using gdc. Take a look at http://d.godbolt.org, I think 
it's pretty darn cool! I'm talking to him about integrating his 
work with our servers.



Andrei


Compare a simple C++ to D and the C++ output is far better:

class C
{
int x = 12;
public:
int foo(int y) { return y*x; }
};

int main()
{
   C* c = new C();
   return c->foo(2);
}



VS




class C
{
int x = 12;
public:
int foo(int y) { return y*x; }
};

int main()
{
   C c = new C();
   return c.foo(2);
}








operator new(unsigned long)@plt:
 jmpQWORD PTR [rip+0x200baa]# 601020 new(unsigned long)@GLIBCXX_3.4>

 push   0x1
 jmp400450 <.plt>
main:
 push   rbp
 movrbp,rsp
 push   rbx
 subrsp,0x18
 movedi,0x4
 call   400470 
 movrbx,rax
 movDWORD PTR [rbx],0x0
 movrdi,rbx
 call   4005bc 
 movQWORD PTR [rbp-0x18],rbx
 movrax,QWORD PTR [rbp-0x18]
 movesi,0x2
 movrdi,rax
 call   4005a4 
 nop
 addrsp,0x18
 poprbx
 poprbp
 ret
 nop
C::foo(int):
 push   rbp
 movrbp,rsp
 movQWORD PTR [rbp-0x8],rdi
 movDWORD PTR [rbp-0xc],esi
 movrax,QWORD PTR [rbp-0x8]
 moveax,DWORD PTR [rax]
 imul   eax,DWORD PTR [rbp-0xc]
 poprbp
 ret
 nop
C::C():
 push   rbp
 movrbp,rsp
 movQWORD PTR [rbp-0x8],rdi
 movrax,QWORD PTR [rbp-0x8]
 movDWORD PTR [rax],0xc
 nop
 poprbp
 ret
 nopWORD PTR cs:[rax+rax*1+0x0]
 nopDWORD PTR [rax+rax*1+0x0]




VS










_Dmain:
 push   rbp
 movrbp,rsp
 subrsp,0x10
 movrdi,QWORD PTR [rip+0x0]# f <_Dmain+0xf>
 call   14 <_Dmain+0x14>
 movQWORD PTR [rbp-0x8],rax
 movesi,0x2
 movrdi,rax
 movrax,QWORD PTR [rax]
 rex.W call QWORD PTR [rax+0x28]
 leave
 ret
 addBYTE PTR [rax],al
main:
 push   rbp
 movrbp,rsp
 subrsp,0x10
 movDWORD PTR [rbp-0x10],edi
 movQWORD PTR [rbp-0x8],rsi
 movrdx,QWORD PTR [rip+0x0]# 16 
 movrsi,QWORD PTR [rbp-0x8]
 movedi,DWORD PTR [rbp-0x10]
 call   22 
 leave
 ret
.text.d_dso_init:
 push   rbp
 movrbp,rsp
 learax,[rip+0x0]# b <.text.d_dso_init+0xb>
 push   rax
 learax,[rip+0x0]# 13 <.text.d_dso_init+0x13>
 push   rax
 learax,[rip+0x0]# 1b <.text.d_dso_init+0x1b>
 push   rax
 push   0x1
 movrdi,rsp
 call   26 <.text.d_dso_init+0x26>
 leave
 ret


the C++ version is more verbose, gives explicit references to 
functions and methods while the D version requires you to hunt 
and peck.




Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread nazriel
On Friday, 21 September 2012 at 07:40:11 UTC, Andrej Mitrovic 
wrote:
On 9/21/12, Andrei Alexandrescu  
wrote:

snip


Integrating this with dpaste would be aweee..sooome!


http://dpaste.dzfl.pl/news/change-log---v0.82

Those are in plans for all compilers but atm, we are struggling 
with problem of exceeding monthly bandwidth. Disassemble output 
takes a lot of space



Anyways, I like design of this website!
Very similar to dpaste, which rox ;>

Looks very nice, probably we could adapt some ideas to dpaste, 
like

__Compiler options__


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread Jens Mueller
Ellery Newcomer wrote:
> On 09/21/2012 03:04 AM, Jens Mueller wrote:
> >But it's nice to have source code and assembly side by side.
> >
> >Jens
> >
> 
> And very nice to have demangled names in assembly.

You can pipe your assembly code to ddemangle if there is some other tool
that missing demangling. I did this for example when I looked at output
from a statistical profiler.

Jens


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread Ellery Newcomer

On 09/21/2012 03:04 AM, Jens Mueller wrote:

But it's nice to have source code and assembly side by side.

Jens



And very nice to have demangled names in assembly.


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread Iain Buclaw
On 21 September 2012 14:49, bearophile  wrote:
>> It seems even this program produces a too much long asm listing for the
>> site:
>>
>> import std.stdio;
>> void main() {
>> writeln("%f", 1.5);
>> }
>
>
> Compiled with:
>
> -O0 -march=native
>
> Bye,
> bearophile


Curse those templates. ;-)

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread bearophile
It seems even this program produces a too much long asm listing 
for the site:


import std.stdio;
void main() {
writeln("%f", 1.5);
}


Compiled with:

-O0 -march=native

Bye,
bearophile


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread bearophile

I'd like a way to filter the output to the
disassembly of just one (or few) functions, because otherwise 
the output risks being too much large.


It seems even this program produces a too much long asm listing 
for the site:


import std.stdio;
void main() {
writeln("%f", 1.5);
}


Bye,
bearophile


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread bearophile

Andrei Alexandrescu:

I've met Matt Goldbolt, the author of the GCC Explorer at 
http://gcc.godbolt.org - a very handy online disassembler for 
GCC.


We got to talk a bit about D and he hacked together support for 
D by using gdc. Take a look at http://d.godbolt.org, I think 
it's pretty darn cool! I'm talking to him about integrating his 
work with our servers.


It's a nice idea. I'd like a way to filter the output to the
disassembly of just one (or few) functions, because otherwise the
output risks being too much large.

At my second try I have received this, I don't know why:





Bye,
bearophile


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread Jens Mueller
Iain Buclaw wrote:
> On 21 September 2012 11:29, Iain Buclaw  wrote:
> > On 21 September 2012 11:17, Bernard Helyer  wrote:
> >> On Friday, 21 September 2012 at 10:04:00 UTC, Jens Mueller wrote:
> >>>
> >>> Andrei Alexandrescu wrote:
> 
>  I've met Matt Goldbolt, the author of the GCC Explorer at
>  http://gcc.godbolt.org - a very handy online disassembler for GCC.
> >>>
> >>>
> >>> This is not a disassembler. It just stops compilation before the
> >>> assembler (gcc -S). A dissembler would create the assembler code given
> >>> only the machine code.
> >>
> >>
> >> You are both correct and incredibly pedantic. :P
> >
> > Half correct and incredibly pedantic. :-)
> >
> > There's two modes.  One is assembler output, the other is objdump
> > output (which is a disassembler).
> >
> 
> And if it doesn't then I must be incredibly confused at this hour in
> the morning (yawns).

How do I use the objdump mode in the web interface?

Jens


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread Iain Buclaw
On 21 September 2012 11:29, Iain Buclaw  wrote:
> On 21 September 2012 11:17, Bernard Helyer  wrote:
>> On Friday, 21 September 2012 at 10:04:00 UTC, Jens Mueller wrote:
>>>
>>> Andrei Alexandrescu wrote:

 I've met Matt Goldbolt, the author of the GCC Explorer at
 http://gcc.godbolt.org - a very handy online disassembler for GCC.
>>>
>>>
>>> This is not a disassembler. It just stops compilation before the
>>> assembler (gcc -S). A dissembler would create the assembler code given
>>> only the machine code.
>>
>>
>> You are both correct and incredibly pedantic. :P
>
> Half correct and incredibly pedantic. :-)
>
> There's two modes.  One is assembler output, the other is objdump
> output (which is a disassembler).
>

And if it doesn't then I must be incredibly confused at this hour in
the morning (yawns).


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread Iain Buclaw
On 21 September 2012 11:17, Bernard Helyer  wrote:
> On Friday, 21 September 2012 at 10:04:00 UTC, Jens Mueller wrote:
>>
>> Andrei Alexandrescu wrote:
>>>
>>> I've met Matt Goldbolt, the author of the GCC Explorer at
>>> http://gcc.godbolt.org - a very handy online disassembler for GCC.
>>
>>
>> This is not a disassembler. It just stops compilation before the
>> assembler (gcc -S). A dissembler would create the assembler code given
>> only the machine code.
>
>
> You are both correct and incredibly pedantic. :P

Half correct and incredibly pedantic. :-)

There's two modes.  One is assembler output, the other is objdump
output (which is a disassembler).

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread Bernard Helyer

On Friday, 21 September 2012 at 10:04:00 UTC, Jens Mueller wrote:

Andrei Alexandrescu wrote:

I've met Matt Goldbolt, the author of the GCC Explorer at
http://gcc.godbolt.org - a very handy online disassembler for 
GCC.


This is not a disassembler. It just stops compilation before the
assembler (gcc -S). A dissembler would create the assembler 
code given

only the machine code.


You are both correct and incredibly pedantic. :P


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread Jens Mueller
Andrei Alexandrescu wrote:
> I've met Matt Goldbolt, the author of the GCC Explorer at
> http://gcc.godbolt.org - a very handy online disassembler for GCC.

This is not a disassembler. It just stops compilation before the
assembler (gcc -S). A dissembler would create the assembler code given
only the machine code.
But it's nice to have source code and assembly side by side.

Jens


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread Jacob Carlborg

On 2012-09-21 05:47, Andrei Alexandrescu wrote:

I've met Matt Goldbolt, the author of the GCC Explorer at
http://gcc.godbolt.org - a very handy online disassembler for GCC.

We got to talk a bit about D and he hacked together support for D by
using gdc. Take a look at http://d.godbolt.org, I think it's pretty darn
cool! I'm talking to him about integrating his work with our servers.


That's pretty cool.

--
/Jacob Carlborg


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread Andrej Mitrovic
On 9/21/12, Andrei Alexandrescu  wrote:
> snip

Integrating this with dpaste would be aweee..sooome!


Re: GDC Explorer - an online disassembler for D

2012-09-21 Thread Iain Buclaw
On 21 September 2012 04:47, Andrei Alexandrescu
 wrote:
> I've met Matt Goldbolt, the author of the GCC Explorer at
> http://gcc.godbolt.org - a very handy online disassembler for GCC.
>
> We got to talk a bit about D and he hacked together support for D by using
> gdc. Take a look at http://d.godbolt.org, I think it's pretty darn cool! I'm
> talking to him about integrating his work with our servers.
>
>
> Andrei

That's awesome. :-)


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


GDC Explorer - an online disassembler for D

2012-09-20 Thread Andrei Alexandrescu
I've met Matt Goldbolt, the author of the GCC Explorer at 
http://gcc.godbolt.org - a very handy online disassembler for GCC.


We got to talk a bit about D and he hacked together support for D by 
using gdc. Take a look at http://d.godbolt.org, I think it's pretty darn 
cool! I'm talking to him about integrating his work with our servers.



Andrei