Skip to content

Commit

Permalink
Add “—endless-trace-buffer” to switch to an endless buffer from a rin…
Browse files Browse the repository at this point in the history
…g buffer while tracing. (flutter#2966)
  • Loading branch information
chinmaygarde authored Aug 23, 2016
1 parent 28e9b3b commit d35e080
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 23 deletions.
1 change: 1 addition & 0 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct Settings {
bool start_paused = false;
bool enable_dart_checked_mode = false;
bool trace_startup = false;
bool endless_trace_buffer = false;
std::string aot_snapshot_path;
std::string aot_isolate_snapshot_file_name;
std::string aot_vm_isolate_snapshot_file_name;
Expand Down
19 changes: 16 additions & 3 deletions runtime/dart_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ static const char* kDartStartPausedArgs[]{

static const char* kDartTraceStartupArgs[]{
"--timeline_streams=Compiler,Dart,Embedder,GC",
};

static const char* kDartEndlessTraceBufferArgs[]{
"--timeline_recorder=endless",
};

Expand Down Expand Up @@ -339,7 +342,8 @@ DartJniIsolateData* GetDartJniDataForCurrentIsolate() {

#if DART_ALLOW_DYNAMIC_RESOLUTION

constexpr char kDartVmIsolateSnapshotBufferName[] = "kDartVmIsolateSnapshotBuffer";
constexpr char kDartVmIsolateSnapshotBufferName[] =
"kDartVmIsolateSnapshotBuffer";
constexpr char kDartIsolateSnapshotBufferName[] = "kDartIsolateSnapshotBuffer";
constexpr char kInstructionsSnapshotName[] = "kInstructionsSnapshot";
constexpr char kDataSnapshotName[] = "kDataSnapshot";
Expand Down Expand Up @@ -422,7 +426,8 @@ void* _DartSymbolLookup(const char* symbol_name) {

const char* file_name = symbol_asset.file_name;
const std::string* settings_override = reinterpret_cast<const std::string*>(
reinterpret_cast<const uint8_t*>(&settings) + symbol_asset.settings_offset);
reinterpret_cast<const uint8_t*>(&settings) +
symbol_asset.settings_offset);
if (!settings_override->empty())
file_name = settings_override->c_str();

Expand Down Expand Up @@ -580,8 +585,16 @@ void InitDartVM() {
if (settings.start_paused)
PushBackAll(&args, kDartStartPausedArgs, arraysize(kDartStartPausedArgs));

if (settings.trace_startup)
if (settings.endless_trace_buffer || settings.trace_startup) {
// If we are tracing startup, make sure the trace buffer is endless so we
// don't lose early traces.
PushBackAll(&args, kDartEndlessTraceBufferArgs,
arraysize(kDartEndlessTraceBufferArgs));
}

if (settings.trace_startup) {
PushBackAll(&args, kDartTraceStartupArgs, arraysize(kDartTraceStartupArgs));
}

for (size_t i = 0; i < settings.dart_flags.size(); i++)
args.push_back(settings.dart_flags[i].c_str());
Expand Down
2 changes: 2 additions & 0 deletions sky/shell/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ void Shell::InitStandalone(std::string icu_data_path) {
settings.start_paused = command_line.HasSwitch(switches::kStartPaused);
settings.enable_dart_checked_mode =
command_line.HasSwitch(switches::kEnableCheckedMode);
settings.endless_trace_buffer =
command_line.HasSwitch(switches::kEndlessTraceBuffer);
settings.trace_startup = command_line.HasSwitch(switches::kTraceStartup);
settings.aot_snapshot_path =
command_line.GetSwitchValueASCII(switches::kAotSnapshotPath);
Expand Down
21 changes: 11 additions & 10 deletions sky/shell/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@ namespace sky {
namespace shell {
namespace switches {

const char kAotInstructionsBlob[] = "instructions-blob";
const char kAotIsolateSnapshot[] = "isolate-snapshot";
const char kAotRodataBlob[] = "rodata-blob";
const char kAotSnapshotPath[] = "aot-snapshot-path";
const char kAotVmIsolateSnapshot[] = "vm-isolate-snapshot";
const char kCacheDirPath[] = "cache-dir-path";
const char kDartFlags[] = "dart-flags";
const char kDeviceObservatoryPort[] = "observatory-port";
const char kEnableCheckedMode[] = "enable-checked-mode";
const char kEndlessTraceBuffer[] = "endless-trace-buffer";
const char kFLX[] = "flx";
const char kHelp[] = "help";
const char kNonInteractive[] = "non-interactive";
const char kMainDartFile[] = "dart-main";
const char kNonInteractive[] = "non-interactive";
const char kNoRedirectToSyslog[] = "no-redirect-to-syslog";
const char kPackages[] = "packages";
const char kStartPaused[] = "start-paused";
const char kTraceStartup[] = "trace-startup";
const char kDeviceObservatoryPort[] = "observatory-port";
const char kAotSnapshotPath[] = "aot-snapshot-path";
const char kAotIsolateSnapshot[] = "isolate-snapshot";
const char kAotVmIsolateSnapshot[] = "vm-isolate-snapshot";
const char kAotInstructionsBlob[] = "instructions-blob";
const char kAotRodataBlob[] = "rodata-blob";
const char kNoRedirectToSyslog[] = "no-redirect-to-syslog";
const char kCacheDirPath[] = "cache-dir-path";
const char kDartFlags[] = "dart-flags";

void PrintUsage(const std::string& executable_name) {
// clang-format off
Expand Down
21 changes: 11 additions & 10 deletions sky/shell/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ namespace sky {
namespace shell {
namespace switches {

extern const char kAotInstructionsBlob[];
extern const char kAotIsolateSnapshot[];
extern const char kAotRodataBlob[];
extern const char kAotSnapshotPath[];
extern const char kAotVmIsolateSnapshot[];
extern const char kCacheDirPath[];
extern const char kDartFlags[];
extern const char kDeviceObservatoryPort[];
extern const char kEnableCheckedMode[];
extern const char kEndlessTraceBuffer[];
extern const char kFLX[];
extern const char kHelp[];
extern const char kNonInteractive[];
extern const char kMainDartFile[];
extern const char kNonInteractive[];
extern const char kNoRedirectToSyslog[];
extern const char kPackages[];
extern const char kStartPaused[];
extern const char kTraceStartup[];
extern const char kDeviceObservatoryPort[];
extern const char kAotSnapshotPath[];
extern const char kAotIsolateSnapshot[];
extern const char kAotVmIsolateSnapshot[];
extern const char kAotInstructionsBlob[];
extern const char kAotRodataBlob[];
extern const char kNoRedirectToSyslog[];
extern const char kCacheDirPath[];
extern const char kDartFlags[];

void PrintUsage(const std::string& executable_name);

Expand Down

0 comments on commit d35e080

Please sign in to comment.