-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i#1729 offline traces: refactor drcachesim to simulate from a trace file
Adds a new option -infile, which directs drcachesim to read a trace file and simulate based on its contents. Changes the launcher to bypass application invocation when this option is selected. Eliminates the shadowed iterator fields in simulator_t added by b11c906. Adds reader setup code to analyzer_t which creates either an ipc_reader_t or a file_reader_t depending on runtime options. Changes the analyzer_t/simulator_t model to initialize in the constructor rather than using an init() function to provide automated invocation of this analyzer_t reader setup code. Success is cached and queried via operator!. Updates cache_simulator_t and tlb_simulator_t for the new shared code in analyzer_t and the new iterator fields. Adds better handling of partially-initialized simulator objects in the simulator destructors. A test is forthcoming. Review-URL: https://codereview.appspot.com/309440043
- Loading branch information
1 parent
2eb7494
commit 357da25
Showing
12 changed files
with
250 additions
and
147 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* ********************************************************** | ||
* Copyright (c) 2016 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. | ||
*/ | ||
|
||
#include "analyzer.h" | ||
#include "common/options.h" | ||
#include "common/utils.h" | ||
#include "reader/file_reader.h" | ||
#include "reader/ipc_reader.h" | ||
|
||
analyzer_t::analyzer_t() : | ||
success(true) | ||
{ | ||
// XXX: add a "required" flag to droption to avoid needing this here | ||
if (op_infile.get_value().empty() && op_ipc_name.get_value().empty()) { | ||
ERROR("Usage error: -ipc_name or -infile is required\nUsage:\n%s", | ||
droption_parser_t::usage_short(DROPTION_SCOPE_ALL).c_str()); | ||
success = false; | ||
return; | ||
} | ||
if (op_infile.get_value().empty()) { | ||
trace_iter = new ipc_reader_t(op_ipc_name.get_value().c_str()); | ||
trace_end = new ipc_reader_t(); | ||
} else { | ||
trace_iter = new file_reader_t(op_infile.get_value().c_str()); | ||
trace_end = new file_reader_t(); | ||
} | ||
// We can't call trace_iter->init() here as it blocks for ipc_reader_t. | ||
} | ||
|
||
analyzer_t::~analyzer_t() | ||
{ | ||
delete trace_iter; | ||
delete trace_end; | ||
} | ||
|
||
bool | ||
analyzer_t::operator!() | ||
{ | ||
return !success; | ||
} | ||
|
||
bool | ||
analyzer_t::start_reading() | ||
{ | ||
if (!trace_iter->init()) { | ||
ERROR("failed to read from %s\n", op_infile.get_value().empty() ? | ||
op_ipc_name.get_value().c_str() : op_infile.get_value().c_str()); | ||
return false; | ||
} | ||
return true; | ||
} |
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
Oops, something went wrong.