Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to include called functions (to some depth) #247

Closed
kpreid opened this issue Feb 7, 2024 · 6 comments · Fixed by #248
Closed

Option to include called functions (to some depth) #247

kpreid opened this issue Feb 7, 2024 · 6 comments · Fixed by #248

Comments

@kpreid
Copy link

kpreid commented Feb 7, 2024

Often, the code that I want to inspect turns out to be in some closure expression, and that closure doesn't necessarily get inlined by the compiler (or perhaps the changes I am making perturb whether or not it's inlined). In this case, it's an extra step to rerun with the generated closure symbol's name.

Therefore, I suggest adding an option which prints, in addition to the selected function's assembly, the assembly for symbols that it calls or otherwise references (up to some max depth, and skipping std symbols by default).

This could even be automatic in the case where the called function is only called by this function.

The logic to support this could also help with #22.

@pacak
Copy link
Owner

pacak commented Feb 8, 2024

Seems doable as long as we are talking about referencing some other code and not checking if it is a call or not. The way it is currently implementing including symbols from std is actually impossible - cargo-show-asm doesn't perform any disassembly, it simply asks rustc to dump asm files it would generate and parses them. Will try to implement it at some point.

@pacak
Copy link
Owner

pacak commented Feb 9, 2024

#248 - I made this. Is it what you had in mind?

@pacak
Copy link
Owner

pacak commented Feb 9, 2024

Going just by references. Detecting actual calls is hard.

        mov r13, qword ptr [rip + rand_core::SeedableRng::seed_from_u64::pcg32@GOTPCREL] <- reference
        lea r14, [rsp + 160]
        mov rdi, r14
        call r13   <- call
        mov ebx, eax
        mov rdi, r14
        call r13   <- call
        mov r15d, eax
        mov rdi, r14
        call r13   <- call
        mov r12d, eax
        vmovd xmm0, eax
        vmovdqa xmmword ptr [rsp + 352], xmm0
        mov rdi, r14
        call r13   <- call
        mov ebp, eax
        vmovd xmm0, ebx
        vmovdqa xmmword ptr [rsp + 336], xmm0
        vpinsrd xmm0, xmm0, r15d, 1
        vmovdqa xmmword ptr [rsp + 304], xmm0
        vpinsrd xmm0, xmm0, r12d, 2
        vmovdqa xmmword ptr [rsp + 320], xmm0
        vpinsrd xmm1, xmm0, eax, 3
        vmovdqu ymmword ptr [rsp + 368], ymm1
        mov rdi, r14
        vzeroupper
        call r13   <- call
        vmovd xmm0, eax
        vpbroadcastd ymm0, xmm0
        vpblendd ymm0, ymm0, ymmword ptr [rsp + 368], 239
        vmovdqu ymmword ptr [rsp + 272], ymm0
        mov rdi, r14
        vzeroupper
        call r13   <- call

@kpreid
Copy link
Author

kpreid commented Feb 10, 2024

#248 - I made this. Is it what you had in mind?

Looks reasonable to me. I haven't tested it.

@pacak
Copy link
Owner

pacak commented Feb 10, 2024

Okay. Will try to release soon-ish after some more experiments with cli options. -ccc seems better than -c 3, but --context --context --context is worse than --context 3 :)

@kpreid
Copy link
Author

kpreid commented Feb 10, 2024

Well, for what it's worth, I'd rather type -c 3 than -ccc.

@pacak pacak mentioned this issue Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants