Re: [PATCH 17/17] perf annotate: Handle variables in 'sub', 'or' and many other instructions
Em Tue, Apr 17, 2018 at 11:56:28AM +0900, Namhyung Kim escreveu: > Hi, > > On Fri, Apr 13, 2018 at 10:39:40AM -0700, Andi Kleen wrote: > > > What do I miss? Or where is it that I'm misinterpreting the calculations > > > that objdump did in its output? > > > > The calculations are right, but these are still two different address modes. > > You cannot just turn one silently into the other. > > > > I think it would be ok to use the syntax in the assembler > > > > symbol(%rip) with no # ... > > One thing I find useful is to show string constant if the address is > in the rodata (and printable of course). Maybe something like below.. > > lea0x1234(%rip),%rdi# "hello world\n" > callq printf > > > Just an idea. Send some more :-) /me adds to the todo.annotate folder... - Arnaldo
Re: [PATCH 17/17] perf annotate: Handle variables in 'sub', 'or' and many other instructions
Hi, On Fri, Apr 13, 2018 at 10:39:40AM -0700, Andi Kleen wrote: > > What do I miss? Or where is it that I'm misinterpreting the calculations > > that objdump did in its output? > > The calculations are right, but these are still two different address modes. > You cannot just turn one silently into the other. > > I think it would be ok to use the syntax in the assembler > > symbol(%rip) with no # ... One thing I find useful is to show string constant if the address is in the rodata (and printable of course). Maybe something like below.. lea0x1234(%rip),%rdi# "hello world\n" callq printf Just an idea. Thanks, Namhyung > > > About something mildly related: what do you think about this: > > http://ref.x86asm.net/, there is a xml file there[1] I'm thinking about > > using, if available on the developer's HOME or some other standard place, > > to provide help about the instructions :-) > > I don't know how well it's going to be maintained. x86 changes a lot > and I've seen a lot of disassembler libraries etc. go stale as the > owner cannot keep up. > > The only semi official maintained descriptions are the XED tables (but those > don't have descriptions) or the PDFs from Intel/AMD. > I suppose could have some hack that talks to a PDF reader and automatically > downloads/searches the PDF. > > If unofficial is ok I would rather port some functionality > from https://github.com/HJLebbink/asm-dude > which has a lot of cool stuff. > > -Andi
Re: [PATCH 17/17] perf annotate: Handle variables in 'sub', 'or' and many other instructions
> What do I miss? Or where is it that I'm misinterpreting the calculations > that objdump did in its output? The calculations are right, but these are still two different address modes. You cannot just turn one silently into the other. I think it would be ok to use the syntax in the assembler symbol(%rip) with no # ... > About something mildly related: what do you think about this: > http://ref.x86asm.net/, there is a xml file there[1] I'm thinking about > using, if available on the developer's HOME or some other standard place, > to provide help about the instructions :-) I don't know how well it's going to be maintained. x86 changes a lot and I've seen a lot of disassembler libraries etc. go stale as the owner cannot keep up. The only semi official maintained descriptions are the XED tables (but those don't have descriptions) or the PDFs from Intel/AMD. I suppose could have some hack that talks to a PDF reader and automatically downloads/searches the PDF. If unofficial is ok I would rather port some functionality from https://github.com/HJLebbink/asm-dude which has a lot of cool stuff. -Andi
Re: [PATCH 17/17] perf annotate: Handle variables in 'sub', 'or' and many other instructions
Em Fri, Apr 13, 2018 at 09:20:43AM -0700, Andi Kleen escreveu: > On Fri, Apr 13, 2018 at 11:01:11AM -0300, Arnaldo Carvalho de Melo wrote: > > From: Arnaldo Carvalho de Melo > > Just like is done for 'mov' and others that can have as source or > > targets variables resolved by objdump, to make them more compact: > > > > - orb$0x4,0x224d71(%rip)# 226ca4 > > <_rtld_global+0xca4> > > + orb$0x4,_rtld_global+0xca4 > That's not equivalent. It could be non rip relative too. You would need > to keep at least the (%rip). So, the function is _dl_start in /lib64/ld-2.26.so, the objdump output is: 1b10 <_dl_start>: 1d1f: 0f 84 ab 00 00 00 je 1dd0 <_dl_start+0x2c0> 1d25: 48 8d 3d 64 3c 22 00lea0x223c64(%rip),%rdi# 225990 <_rtld_global+0x990> 1d2c: 80 0d 71 3f 22 00 04orb$0x4,0x223f71(%rip)# 225ca4 <_rtld_global+0xca4> 1d33: e8 78 92 00 00 callq afb0 <_dl_setup_hash> Then... 21: 00225000 3960 OBJECT GLOBAL DEFAULT 20 _rtld_global@@GLIBC_PRIVATE 0x225ca4 = 0x225000 + 0x0xca4 And that is equal to 0x1d33 + 0x223f71 What do I miss? Or where is it that I'm misinterpreting the calculations that objdump did in its output? This is just to make things compact, on the TUI if one wants to see the original its just a matter of pressing 'o', i.e. that line appears by default as: perf annotate _dl_start press HOME press /orb │215: lea_rtld_global+0x990,%rdi │ orb$0x4,_rtld_global+0xca4 │ → callq _dl_setup_hash press 'o', to see details, i.e. was this encoded as rip-relative? │1f25: lea0x224a64(%rip),%rdi# 226990 <_rtld_global+0x990> │1f2c: orb$0x4,0x224d71(%rip)# 226ca4 <_rtld_global+0xca4> │1f33: → callq b080 <_dl_setup_hash> Now, if we have a non-rip relative orb, lemme search one with: perf annotate --stdio2 /orb There, we have one in the kernel's sys_pselect6: perf annotate sys_pselect6 /orb │ mov%gs:0x15b40,%rax │ orb$0x4,0x490(%rax) │ mov%rdx,0x718(%rax) │ mov(%rax),%rdx No variables resolved, nothing done, press 'o' to see the original objdump disassembled line: │8128af29: mov%gs:0x15b40,%rax │8128af32: orb$0x4,0x490(%rax) │8128af39: mov%rdx,0x718(%rax) │8128af40: mov(%rax),%rdx About something mildly related: what do you think about this: http://ref.x86asm.net/, there is a xml file there[1] I'm thinking about using, if available on the developer's HOME or some other standard place, to provide help about the instructions :-) - Arnaldo [1] http://ref.x86asm.net/x86reference.xml look for PUNPCKHQDQ 66 10 PUNPCKHQDQ V dq W dq sse2 simdint shunpck Unpack High Data 8-)
Re: [PATCH 17/17] perf annotate: Handle variables in 'sub', 'or' and many other instructions
On Fri, Apr 13, 2018 at 11:01:11AM -0300, Arnaldo Carvalho de Melo wrote: > From: Arnaldo Carvalho de Melo > > Just like is done for 'mov' and others that can have as source or > targets variables resolved by objdump, to make them more compact: > > - orb$0x4,0x224d71(%rip)# 226ca4 > <_rtld_global+0xca4> > + orb$0x4,_rtld_global+0xca4 That's not equivalent. It could be non rip relative too. You would need to keep at least the (%rip). -Andi