Skip to content

process: replace fileToMapping map with OpenELFMapping#1402

Draft
nsavoire wants to merge 1 commit into
open-telemetry:mainfrom
DataDog:nsavoire/remove_file_to_mapping
Draft

process: replace fileToMapping map with OpenELFMapping#1402
nsavoire wants to merge 1 commit into
open-telemetry:mainfrom
DataDog:nsavoire/remove_file_to_mapping

Conversation

@nsavoire
Copy link
Copy Markdown
Contributor

@nsavoire nsavoire commented May 7, 2026

Replace the systemProcess.fileToMapping map (populated as a side effect of IterateMappings, then consulted by OpenELF) with an explicit OpenELFMapping(*RawMapping) method on the Process interface. The mapping is now passed directly, removing the temporal coupling between the two methods and the path-keyed lookup.

In processmanager.newFrameMapping, a small mappingELFOpener adapter routes opens of the bound mapping's path to OpenELFMapping while forwarding everything else (e.g. .gnu_debuglink targets) to OpenELF.

This also fixes some issues with fileToMapping:

Replace the `systemProcess.fileToMapping` map (populated as a side
effect of IterateMappings, then consulted by OpenELF) with an
explicit `OpenELFMapping(*RawMapping)` method on the Process
interface. The mapping is now passed directly, removing the temporal
coupling between the two methods and the path-keyed lookup.

In processmanager.newFrameMapping, a small `mappingELFOpener` adapter
routes opens of the bound mapping's path to `OpenELFMapping` while
forwarding everything else (e.g. .gnu_debuglink targets) to `OpenELF`.

This also fixes some issues with `fileToMapping`:
- The first iteration after process creation missed the map_files
  route because `sp.fileToMapping` was assigned only at the end of
  `IterateMappings` and subsequent iterations could use a stale
  RawMapping (from the previous iteration).
- Avoid path-keyed lookup that could pick the wrong file in some
  very rare cases (open-telemetry#812).
Copy link
Copy Markdown
Contributor

@fabled fabled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This and other clean ups have been on my to-do list for too long. So making forward here is great!

But could this be done without the new method? See the comment.

Comment thread process/types.go
// OpenELFMapping opens a memory mapping as an ELF file. The mapping must
// originate from this Process (via IterateMappings), passing a foreign
// mapping has undefined results.
OpenELFMapping(*RawMapping) (*pfelf.File, error)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding this as new method, could there be helper that just calls OpenMappingFile and then calls pfelf.OpenELF.

I'd also like to get rid of the `OpenELF' method here.

After #1395 things should work good with this approach.

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.

2 participants