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

i#2062 memtrace nonmod part 2: Raw2trace parsing of encoding file #5619

Merged
merged 7 commits into from
Aug 19, 2022

Conversation

derekbruening
Copy link
Contributor

Adds raw2trace parsing of the encoding file used by the tracer to
store instruction encodings for generated code. This involves the
following changes:

  • Adds encoding file parsing to module_mapper_t.
  • Changes module map queries to use new module_mapper_t interfaces instead,
    which handle generated code.
  • Changes block lookup to use the modidx,modoffs pair as the key rather than
    the absolute pc.

The changes are compatibility-breaking for raw2trace_t which now takes
an encoding file parameter in the middle of existing parameters.
Updates existing uses.

For module_mapper_t the encoding file is added last with a default
value to preserve compatibility for existing analysis tools like
opcode_mix and view. It is assumed that encodings for generated code
will be added to the final trace file and thus these tools will not
need a module_mapper_t interface for generated code.

Augments the tool.drcacheoff.gencode test to post-process the trace
and ensure the generated code PC is observed.

Fixes a -loglevel 4 signal dump_unmaksed() crash on detach i#5618 hit
in the gencode test; confirmed the test is crash-free at loglevel 4
with the fix.

Issue: #2062
Fixes #5618

Adds raw2trace parsing of the encoding file used by the tracer to
store instruction encodings for generated code.  This involves the
following changes:

+ Adds encoding file parsing to module_mapper_t.
+ Changes module map queries to use new module_mapper_t interfaces instead,
  which handle generated code.
+ Changes block lookup to use the modidx,modoffs pair as the key rather than
  the absolute pc.

The changes are compatibility-breaking for raw2trace_t which now takes
an encoding file parameter in the middle of existing parameters.
Updates existing uses.

For module_mapper_t the encoding file is added last with a default
value to preserve compatibility for existing analysis tools like
opcode_mix and view.  It is assumed that encodings for generated code
will be added to the final trace file and thus these tools will not
need a module_mapper_t interface for generated code.

Augments the tool.drcacheoff.gencode test to post-process the trace
and ensure the generated code PC is observed.

Fixes a -loglevel 4 signal dump_unmaksed() crash on detach i#5618 hit
in the gencode test; confirmed the test is crash-free at loglevel 4
with the fix.

Issue: #2062
Fixes #5618
…ashtable_t for 64-bit by adding a wrapper class block_hashtable_t
@derekbruening
Copy link
Contributor Author

Blocked on the 32-bit hash keys where modidx:modoffs doesn't fit in hashtable_t's pointer-sized keys: so I'm using std::unordered_map (despite it being slower) for 32-bit which works for Linux, but on Windows the compiler doesn't seem to be using a move instead of a copy for the unique_ptr. Still trying to figure out a way through...

@derekbruening
Copy link
Contributor Author

Seems to be a known Visual Studio headache.
Found a workaround here: https://www.reddit.com/r/cpp/comments/6q94ai/comment/dkwdd8l/

@derekbruening
Copy link
Contributor Author

There seem to be non-deterministic (32-bit was just green) Windows timeouts: very frustrating to deal with (see the poor unique_ptr support in Visual Studio I already had to work around). Please go ahead with the review and see if you can spot anything. Not looking forward to more Windows mess that may well turn out to be purely caused by the compiler.

@derekbruening
Copy link
Contributor Author

There seem to be non-deterministic (32-bit was just green) Windows timeouts: very frustrating to deal with (see the poor unique_ptr support in Visual Studio I already had to work around). Please go ahead with the review and see if you can spot anything. Not looking forward to more Windows mess that may well turn out to be purely caused by the compiler.

Turns out this is not related to the unique_ptr: I managed to reproduce in a Windows machine. It is the mmap size being expanded to a page boundary and a check vs map instead of file size. I am uploading the fix in do_encoding_parse().

clients/drcachesim/tracer/raw2trace.cpp Show resolved Hide resolved
clients/drcachesim/tracer/raw2trace.cpp Show resolved Hide resolved
clients/drcachesim/tests/raw2trace_unit_tests.cpp Outdated Show resolved Hide resolved
clients/drcachesim/tracer/raw2trace.cpp Show resolved Hide resolved
@derekbruening
Copy link
Contributor Author

32-bit scattergather test failed again with the same assert: #5329.

@derekbruening derekbruening merged commit 91c304a into master Aug 19, 2022
@derekbruening derekbruening deleted the i2062-emit-encodings branch August 19, 2022 20:58
derekbruening added a commit that referenced this pull request Aug 26, 2022
)

Adds raw2trace parsing of the encoding file used by the tracer to
store instruction encodings for generated code.  This involves the
following changes:

+ Adds encoding file parsing to module_mapper_t.
+ Changes module map queries to use new module_mapper_t interfaces instead,
  which handle generated code.
+ Changes block lookup to use the modidx,modoffs pair as the key rather than
  the absolute pc.  This runs into problems on 32-bit where the hashtable_t key
  is limited to pointer-sized.  To solve this, on 32-bit we use unordered_map, via
  a wrapper class block_hashtable_t to abstract away the differences.

The changes are compatibility-breaking for raw2trace_t which now takes
an encoding file parameter in the middle of existing parameters.
Updates existing uses.

For module_mapper_t the encoding file is added last with a default
value to preserve compatibility for existing analysis tools like
opcode_mix and view.  It is assumed that encodings for generated code
will be added to the final trace file and thus these tools will not
need a module_mapper_t interface for generated code.

Augments the tool.drcacheoff.gencode test to post-process the trace
and ensure the generated code PC is observed.

Fixes a -loglevel 4 signal dump_unmaksed() crash on detach i#5618 hit
in the gencode test; confirmed the test is crash-free at loglevel 4
with the fix.

Issue: #2062
Fixes #5618
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.

CRASH on detach at -loglevel 4 in dump_unmasked
2 participants