-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i#7031: invalidate CPU marker filter
In some cases we don't want to expose the "as traced" CPU schedule in an offline trace because it might not be representative of the native execution of the traced program. To do so we implement `invalidate_cpu_filter_t`, a new filter that is used with `record_filter` as follows: ``` drrun -t drmemtrace -tool record_filter -filter_invalidate_cpu -indir path/to/input/trace -outdir path/to/output/trace ``` This filter set the value of TRACE_MARKER_TYPE_CPU_ID markers to (uintptr_t)-1, which representes an unknown CPU. We add a unit test `test_invalidate_cpu_filter()` and an end-to-end test `code_api|tool.record_filter_invalidate_cpu` which invokes the `invariant_checker` and `view` tool on the filtered trace. Fixes #7031
- Loading branch information
Showing
12 changed files
with
221 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
clients/drcachesim/tests/record_filter_invalidate_cpu.templatex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Estimation of pi is 3.142425985001098 | ||
|
||
Trace invariant checks passed | ||
|
||
Output .* entries from .* entries. | ||
|
||
Output format: | ||
|
||
<--record#-> <--instr#->: <---tid---> <record details> | ||
|
||
------------------------------------------------------------ | ||
|
||
1 0: +[0-9]+ <marker: version [0-9]> | ||
2 0: +[0-9]+ <marker: filetype 0x[0-9a-f]*> | ||
3 0: +[0-9]+ <marker: cache line size [0-9]*> | ||
4 0: +[0-9]+ <marker: chunk instruction count [0-9]*> | ||
5 0: +[0-9]+ <marker: page size [0-9]*> | ||
6 0: +[0-9]+ <marker: timestamp [0-9]*> | ||
#ifdef X64 | ||
7 0: +[0-9]+ <marker: tid [0-9]* on core 18446744073709551615> | ||
#else | ||
7 0: +[0-9]+ <marker: tid [0-9]* on core 4294967295> | ||
#endif | ||
.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* ********************************************************** | ||
* Copyright (c) 2024 Google, Inc. All rights reserved. | ||
* **********************************************************/ | ||
|
||
/* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* * Neither the name of Google, Inc. nor the names of its contributors may be | ||
* used to endorse or promote products derived from this software without | ||
* specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL VMWARE, INC. OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
* DAMAGE. | ||
*/ | ||
|
||
#ifndef _INVALIDATE_CPU_FILTER_H_ | ||
#define _INVALIDATE_CPU_FILTER_H_ 1 | ||
|
||
#include "record_filter.h" | ||
#include "trace_entry.h" | ||
|
||
#include <cstring> | ||
|
||
#define INVALID_CPU_MARKER_VALUE ~((addr_t)0UL) | ||
|
||
namespace dynamorio { | ||
namespace drmemtrace { | ||
|
||
/* This filter invalidates the value of TRACE_MARKER_TYPE_CPU_ID by setting its value to | ||
* (uintptr_t)-1, which indicates that the CPU could not be determined. | ||
*/ | ||
class invalidate_cpu_filter_t : public record_filter_t::record_filter_func_t { | ||
public: | ||
invalidate_cpu_filter_t() | ||
{ | ||
} | ||
|
||
void * | ||
parallel_shard_init(memtrace_stream_t *shard_stream, | ||
bool partial_trace_filter) override | ||
{ | ||
return nullptr; | ||
} | ||
|
||
bool | ||
parallel_shard_filter( | ||
trace_entry_t &entry, void *shard_data, | ||
record_filter_t::record_filter_info_t &record_filter_info) override | ||
{ | ||
trace_type_t entry_type = static_cast<trace_type_t>(entry.type); | ||
// Output any trace_entry_t that it's not a marker. | ||
if (entry_type != TRACE_TYPE_MARKER) | ||
return true; | ||
|
||
trace_marker_type_t marker_type = static_cast<trace_marker_type_t>(entry.size); | ||
// Output any trace_entry_t that it's not a CPU marker. | ||
if (marker_type != TRACE_MARKER_TYPE_CPU_ID) | ||
return true; | ||
|
||
// Invalidate CPU marker value. | ||
entry.addr = INVALID_CPU_MARKER_VALUE; | ||
|
||
return true; | ||
} | ||
|
||
bool | ||
parallel_shard_exit(void *shard_data) override | ||
{ | ||
return true; | ||
} | ||
}; | ||
|
||
} // namespace drmemtrace | ||
} // namespace dynamorio | ||
#endif /* _INCALIDATE_CPU_FILTER_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters