Skip to content

Instantly share code, notes, and snippets.

@tesuji
Last active December 30, 2018 10:03
Show Gist options
  • Save tesuji/84f757883bd074ec447c8754eef87718 to your computer and use it in GitHub Desktop.
Save tesuji/84f757883bd074ec447c8754eef87718 to your computer and use it in GitHub Desktop.

With rustgdb:

(gdb) x/75i drop::main 
   0x7d90 <drop::main>:	sub    rsp,0xa8
   0x7d97 <drop::main+7>:	lea    rax,[rip+0x4bc0a]        # 0x539a8
   0x7d9e <drop::main+14>:	mov    ecx,0x8
   0x7da3 <drop::main+19>:	mov    edx,ecx
   0x7da5 <drop::main+21>:	lea    rdi,[rsp+0x18]
   0x7daa <drop::main+26>:	mov    rsi,rax
   0x7dad <drop::main+29>:	call   0xa760 <<alloc::string::String as core::convert::From<&'a str>>::from>
   0x7db2 <drop::main+34>:	jmp    0x7dc3 <drop::main+51>
   0x7db4 <drop::main+36>:	mov    rdi,QWORD PTR [rsp+0x98]
   0x7dbc <drop::main+44>:	call   0x6860 <_Unwind_Resume@plt>
   0x7dc1 <drop::main+49>:	ud2    
   0x7dc3 <drop::main+51>:	mov    rax,QWORD PTR [rsp+0x28]
   0x7dc8 <drop::main+56>:	mov    QWORD PTR [rsp+0x10],rax
   0x7dcd <drop::main+61>:	movups xmm0,XMMWORD PTR [rsp+0x18]
   0x7dd2 <drop::main+66>:	movaps XMMWORD PTR [rsp],xmm0
   0x7dd6 <drop::main+70>:	lea    rsi,[rip+0x4bbd3]        # 0x539b0
   0x7ddd <drop::main+77>:	lea    rdi,[rsp+0x50]
   0x7de2 <drop::main+82>:	mov    edx,0xb
   0x7de7 <drop::main+87>:	call   0xa760 <<alloc::string::String as core::convert::From<&'a str>>::from>
   0x7dec <drop::main+92>:	jmp    0x7dee <drop::main+94>
   0x7dee <drop::main+94>:	mov    rax,QWORD PTR [rsp+0x60]
   0x7df3 <drop::main+99>:	mov    QWORD PTR [rsp+0x40],rax
   0x7df8 <drop::main+104>:	movups xmm0,XMMWORD PTR [rsp+0x50]
   0x7dfd <drop::main+109>:	movaps XMMWORD PTR [rsp+0x30],xmm0
   0x7e02 <drop::main+114>:	lea    rsi,[rip+0x25fe5f]        # 0x267c68
   0x7e09 <drop::main+121>:	lea    rcx,[rip+0x4bbc8]        # 0x539d8
   0x7e10 <drop::main+128>:	xor    edx,edx
   0x7e12 <drop::main+130>:	mov    r8d,edx
   0x7e15 <drop::main+133>:	lea    rdi,[rsp+0x68]
   0x7e1a <drop::main+138>:	mov    edx,0x1
   0x7e1f <drop::main+143>:	call   0x6b50 <core::fmt::Arguments::new_v1>
   0x7e24 <drop::main+148>:	jmp    0x7e30 <drop::main+160>
   0x7e26 <drop::main+150>:	mov    rdi,rsp
   0x7e29 <drop::main+153>:	call   0x9930 <core::ptr::drop_in_place>
   0x7e2e <drop::main+158>:	jmp    0x7db4 <drop::main+36>
   0x7e30 <drop::main+160>:	lea    rax,[rip+0x7079]        # 0xeeb0 <std::io::stdio::_print>
   0x7e37 <drop::main+167>:	lea    rdi,[rsp+0x68]
   0x7e3c <drop::main+172>:	call   rax
   0x7e3e <drop::main+174>:	jmp    0x7e4c <drop::main+188>
   0x7e40 <drop::main+176>:	lea    rdi,[rsp+0x30]
   0x7e45 <drop::main+181>:	call   0x9930 <core::ptr::drop_in_place>
   0x7e4a <drop::main+186>:	jmp    0x7e26 <drop::main+150>
   0x7e4c <drop::main+188>:	lea    rdi,[rsp+0x30]
   0x7e51 <drop::main+193>:	call   0x9930 <core::ptr::drop_in_place>
   0x7e56 <drop::main+198>:	jmp    0x7e58 <drop::main+200>
   0x7e58 <drop::main+200>:	mov    rdi,rsp
   0x7e5b <drop::main+203>:	call   0x9930 <core::ptr::drop_in_place>
   0x7e60 <drop::main+208>:	add    rsp,0xa8
   0x7e67 <drop::main+215>:	ret    
   0x7e68 <drop::main+216>:	mov    ecx,edx
   0x7e6a <drop::main+218>:	mov    QWORD PTR [rsp+0x98],rax
   0x7e72 <drop::main+226>:	mov    DWORD PTR [rsp+0xa0],ecx
   0x7e79 <drop::main+233>:	jmp    0x7e26 <drop::main+150>
   0x7e7b <drop::main+235>:	mov    ecx,edx
   0x7e7d <drop::main+237>:	mov    QWORD PTR [rsp+0x98],rax
   0x7e85 <drop::main+245>:	mov    DWORD PTR [rsp+0xa0],ecx
   0x7e8c <drop::main+252>:	jmp    0x7e40 <drop::main+176>

With r2:

[0x00006910]> s sym.drop::main::h68a0126b05e2e2db 
[0x00007d90]> af
[0x00007d90]> pdf
┌ (fcn) sym.drop::main::h68a0126b05e2e2db 179
│   sym.drop::main::h68a0126b05e2e2db ();
           ; var int local_10h @ rsp+0x10
           ; var int local_18h @ rsp+0x18
           ; var int local_28h @ rsp+0x28
           ; var int local_30h @ rsp+0x30
           ; var int local_40h @ rsp+0x40
           ; var int local_50h @ rsp+0x50
           ; var int local_60h @ rsp+0x60
           ; var int local_68h @ rsp+0x68
0x00007d90      sub rsp, 0xa8
0x00007d97      lea rax, str.my_stuffother_stuffCustomSmartPointers_created.__called__Result::unwrap____on_an__Err__value: ; 0x539a8 ; "my stuffother stuffCustomSmartPointers created.\ncalled `Result::unwrap()` on an `Err` value: "
0x00007d9e      mov ecx, 8
0x00007da3      mov edx, ecx
0x00007da5      lea rdi, [local_18h]                       ; 0x18
0x00007daa      mov rsi, rax
0x00007dad      call sym._alloc::string::String_as_core::convert::From___a_str__::from::h1bc88c722bc1d039
│       ┌─< 0x00007db2      jmp 0x7dc3
..
│      ╎│   ; CODE XREF from sym.drop::main::h68a0126b05e2e2db (0x7db2)
│      ╎└─> 0x00007dc3      mov rax, qword [local_28h]                 ; [0x28:8]=0x3f09a8 ; '('
│      ╎    0x00007dc8      mov qword [local_10h], rax
│      ╎    0x00007dcd      movups xmm0, xmmword [local_18h]           ; [0x18:16]=-1
│      ╎    0x00007dd2      movaps xmmword [rsp], xmm0
│      ╎    0x00007dd6      lea rsi, [0x000539b0]                      ; "other stuffCustomSmartPointers created.\ncalled `Result::unwrap()` on an `Err` value: "
│      ╎    0x00007ddd      lea rdi, [local_50h]                       ; "@" ; 0x50 ; 'P'
│      ╎    0x00007de2      mov edx, 0xb
│      ╎    0x00007de7      call sym._alloc::string::String_as_core::convert::From___a_str__::from::h1bc88c722bc1d039
│      ╎┌─< 0x00007dec      jmp 0x7dee
│      ╎│   ; CODE XREF from sym.drop::main::h68a0126b05e2e2db (0x7dec)
│      ╎└─> 0x00007dee      mov rax, qword [local_60h]                 ; [0x60:8]=0x230 ; '`'
│      ╎    0x00007df3      mov qword [local_40h], rax
│      ╎    0x00007df8      movups xmm0, xmmword [local_50h]           ; [0x50:16]=-1 ; 'P'
│      ╎    0x00007dfd      movaps xmmword [local_30h], xmm0
│      ╎    0x00007e02      lea rsi, [0x00267c68]
│      ╎    0x00007e09      lea rcx, [0x000539d8]                      ; "called `Result::unwrap()` on an `Err` value: "
│      ╎    0x00007e10      xor edx, edx
│      ╎    0x00007e12      mov r8d, edx
│      ╎    0x00007e15      lea rdi, [local_68h]                       ; 0x68 ; 'h'
│      ╎    0x00007e1a      mov edx, 1
│      ╎    0x00007e1f      call sym.core::fmt::Arguments::new_v1::h8146c9ba413f1644
│      ╎┌─< 0x00007e24      jmp 0x7e30
..
│     ╎ │   ; CODE XREF from sym.drop::main::h68a0126b05e2e2db (0x7e24)
│     ╎ └─> 0x00007e30      lea rax, sym.std::io::stdio::_print::hacb4478e3e4d6959 ; 0xeeb0 ; "AVSH\x81\xec\xc8"
│     ╎     0x00007e37      lea rdi, [local_68h]                       ; 0x68 ; 'h'
│     ╎     0x00007e3c      call rax
│     ╎ ┌─< 0x00007e3e      jmp 0x7e4c
..
│       │   ; CODE XREF from sym.drop::main::h68a0126b05e2e2db (0x7e3e)
│       └─> 0x00007e4c      lea rdi, [local_30h]                       ; sym.je_tsd_tls ; 0x30
0x00007e51      call sym.core::ptr::drop_in_place::h2f8113dbca93872b
│       ┌─< 0x00007e56      jmp 0x7e58
│       │   ; CODE XREF from sym.drop::main::h68a0126b05e2e2db (0x7e56)
│       └─> 0x00007e58      mov rdi, rsp
0x00007e5b      call sym.core::ptr::drop_in_place::h2f8113dbca93872b
0x00007e60      add rsp, 0xa8
0x00007e67      ret

With pdr:

[0x00007d90]> pdr
┌ (fcn) sym.drop::main::h68a0126b05e2e2db 179
│   sym.drop::main::h68a0126b05e2e2db ();
 ; var int local_10h @ rsp+0x10
 ; var int local_18h @ rsp+0x18
 ; var int local_28h @ rsp+0x28
 ; var int local_30h @ rsp+0x30
 ; var int local_40h @ rsp+0x40
 ; var int local_50h @ rsp+0x50
 ; var int local_60h @ rsp+0x60
 ; var int local_68h @ rsp+0x68
0x00007d90      sub rsp, 0xa8
0x00007d97      lea rax, str.my_stuffother_stuffCustomSmartPointers_created.__called__Result::unwrap____on_an__Err__value: ; 0x539a8 ; "my stuffother stuffCustomSmartPointers created.\ncalled `Result::unwrap()` on an `Err` value: "
0x00007d9e      mov ecx, 8
0x00007da3      mov edx, ecx
0x00007da5      lea rdi, [local_18h]                                 ; 0x18
0x00007daa      mov rsi, rax
0x00007dad      call sym._alloc::string::String_as_core::convert::From___a_str__::from::h1bc88c722bc1d039
0x00007db2      jmp 0x7dc3
| ----------- true: 0x00007dc3
 ; CODE XREF from sym.drop::main::h68a0126b05e2e2db (0x7db2)
0x00007dc3      mov rax, qword [local_28h]                           ; [0x28:8]=0x3f09a8 ; '('
0x00007dc8      mov qword [local_10h], rax
0x00007dcd      movups xmm0, xmmword [local_18h]                     ; [0x18:16]=-1
0x00007dd2      movaps xmmword [rsp], xmm0
0x00007dd6      lea rsi, [0x000539b0]                                ; "other stuffCustomSmartPointers created.\ncalled `Result::unwrap()` on an `Err` value: "
0x00007ddd      lea rdi, [local_50h]                                 ; "@" ; 0x50 ; 'P'
0x00007de2      mov edx, 0xb
0x00007de7      call sym._alloc::string::String_as_core::convert::From___a_str__::from::h1bc88c722bc1d039
0x00007dec      jmp 0x7dee
| ----------- true: 0x00007dee
 ; CODE XREF from sym.drop::main::h68a0126b05e2e2db (0x7dec)
0x00007dee      mov rax, qword [local_60h]                           ; [0x60:8]=0x230 ; '`'
0x00007df3      mov qword [local_40h], rax
0x00007df8      movups xmm0, xmmword [local_50h]                     ; [0x50:16]=-1 ; 'P'
0x00007dfd      movaps xmmword [local_30h], xmm0
0x00007e02      lea rsi, [0x00267c68]
0x00007e09      lea rcx, [0x000539d8]                                ; "called `Result::unwrap()` on an `Err` value: "
0x00007e10      xor edx, edx
0x00007e12      mov r8d, edx
0x00007e15      lea rdi, [local_68h]                                 ; 0x68 ; 'h'
0x00007e1a      mov edx, 1
0x00007e1f      call sym.core::fmt::Arguments::new_v1::h8146c9ba413f1644
0x00007e24      jmp 0x7e30
| ----------- true: 0x00007e30
 ; CODE XREF from sym.drop::main::h68a0126b05e2e2db (0x7e24)
0x00007e30      lea rax, sym.std::io::stdio::_print::hacb4478e3e4d6959 ; 0xeeb0 ; "AVSH\x81\xec\xc8"
0x00007e37      lea rdi, [local_68h]                                 ; 0x68 ; 'h'
0x00007e3c      call rax
0x00007e3e      jmp 0x7e4c
| ----------- true: 0x00007e4c
 ; CODE XREF from sym.drop::main::h68a0126b05e2e2db (0x7e3e)
0x00007e4c      lea rdi, [local_30h]                                 ; sym.je_tsd_tls ; 0x30
0x00007e51      call sym.core::ptr::drop_in_place::h2f8113dbca93872b
0x00007e56      jmp 0x7e58
| ----------- true: 0x00007e58
 ; CODE XREF from sym.drop::main::h68a0126b05e2e2db (0x7e56)
0x00007e58      mov rdi, rsp
0x00007e5b      call sym.core::ptr::drop_in_place::h2f8113dbca93872b
0x00007e60      add rsp, 0xa8
0x00007e67      ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment