Skip to content

Recover inlined function for issue #53 - #96

Open
kami922 wants to merge 8 commits into
mandiant:masterfrom
kami922:issue-53-inlined-functions
Open

kami922 wants to merge 8 commits into
mandiant:masterfrom
kami922:issue-53-inlined-functions

Conversation

@kami922

@kami922 kami922 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

closes #53
PR attempts implementation to recover inline functions
reference PR #59

kami922 added 4 commits June 5, 2026 03:55
- Add InlinedCall struct and InlinedList field to FuncMetadata
- Add add(), multiply(), neverInlined() to testproject
- Add comprehensive inline test suite (positive + negative cases)
- Positive tests intentionally fail — implementation not yet written
Constant arguments let the compiler fold add(1,2)/multiply(3,4) into
literals at compile time, leaving no inline-tree evidence to recover
regardless of extraction-code correctness. Deriving from len(os.Args)
forces the compiler to keep real, recoverable inlined instructions.

Also strengthen main_test.go to check for main.multiply by name, not
just main.add, now that both are genuinely recoverable.
…functions

# Conflicts:
#	testproject/main.go
Reads moduledata.gofunc (go:func.* base) via the existing per-version
layout tables, needed for FUNCDATA_InlTree offsets (issue mandiant#53).
Offset 320/64-bit, 160/32-bit verified against runtime source and a
real test binary; the Go 1.26-only layout bucket is left unset rather
than guessed.
@kami922

kami922 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@stevemk14ebr Hello Any update on this? or should I just pull in next commit lemme know your response.
also for now can we go for flat option like (a->b->c) for now will show a called b and a called c . and when this pr gets merged and passes the benchmark than go for dynamic view?

@stevemk14ebr

Copy link
Copy Markdown
Collaborator

You are free to continue work if you like. If you do we would prefer the tree version and would want a single final and complete PR

…ng design (issue mandiant#53)

- InlinedCall gains ParentIndex int (-1 = parent is ParentEntry; else index
  of another record in the same InlinedList).
- testproject/main.go: new nestedOuter/nestedInner fixture (ported from
  learning/03_nested_inline) exercising real 2-level mid-stack inlining,
  with the sink-write trick so nestedInner can't be constant-folded away.
- main_test.go: new positive assertion that nestedInner.ParentIndex resolves
  to nestedOuter's own index, not flattened to main.main -- the check that
  would have caught the flat design.

No extraction logic changed -- these assertions are intentionally failing
until the InlTree parsing commits land.
npcdata(), nfuncdata(), pcdataOffset(), funcdataOffset() on funcData,
following the existing field() pattern. nfuncdata() and the new
headerSize() helper derive their byte offset from sz0 (same computation
field() already does) instead of hardcoding 43/44, so they stay correct
for Go 1.18+ on any bitness rather than only the one binary this was
hand-verified against.

Not yet called anywhere -- wiring these into real InlTree parsing is
the next commit.
…ant#53)

decodePcValueRanges() walks the same delta-encoded pc-value table
pcvalue() already reads (LEB128 varint + zigzag via step()), but returns
every (value, pcStart, pcEnd) transition instead of stopping at one
target PC -- needed later to find every disjoint chunk belonging to a
given InlTree record.

countInlineRecords() derives the record count as max(all non-negative
values) + 1, Delve's approach (maxInlineTreeIndexValue()) -- nothing on
disk states the count directly. Verified against hand-decoded data on
learning/01_basic_inline and learning/02_runtime_inline.

Not yet wired to anything -- InlTree record parsing is next.
@kami922

kami922 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@stevemk14ebr Please review when you get time and let know how to proceed further. Please note the CI tests will still fail and that is expected because there is nothing to be wired in significantly.

@stevemk14ebr

stevemk14ebr commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Please work to a complete PR, I will review at that point.

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 this pull request may close these issues.

Research Inlined Instance data

2 participants