Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
42 changes: 29 additions & 13 deletions packages/android-performance-profiler/cpp-profiler/src/atrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,41 @@ bool includes(std::string str, std::string portion)
return str.find(portion) != std::string::npos;
}

void readATrace()
std::ifstream getTraceStream()
{
std::string traceOutputPath = "/sys/kernel/debug/tracing/trace_pipe";
std::string traceOutputPath1 = "/sys/kernel/debug/tracing/trace_pipe";
// This seems to be an alternative path for certain devices
std::string traceOutputPath2 = "/sys/kernel/tracing/trace_pipe";

std::ifstream traceFile1(traceOutputPath1);

if (traceFile1.is_open())
{
return traceFile1;
}

traceFile1.close();

std::ifstream traceFile(traceOutputPath);
if (traceFile.is_open())
std::ifstream traceFile2(traceOutputPath2);
if (traceFile2.is_open())
{
while (traceFile.good())
{
std::string line;
std::getline(traceFile, line);
addToATraceLines(line);
}
traceFile.close();
return traceFile2;
}
else

throw std::runtime_error("Unable to find Atrace output file");
}

void readATrace()
{
std::ifstream traceFile = getTraceStream();

while (traceFile.good())
{
std::cout << "Unable to open file";
std::string line;
std::getline(traceFile, line);
addToATraceLines(line);
}
traceFile.close();
}

void readATraceThread()
Expand Down
4 changes: 4 additions & 0 deletions packages/android-performance-profiler/src/commands/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export const executeAsync = (command: string): ChildProcess => {
Logger.debug(`Process for ${command} ended`);
});

childProcess.stderr?.on("data", (data) => {
Logger.error(`Process for ${command} errored with ${data.toString()}`);
});

childProcess.on("close", (code) => {
Logger.debug(`child process exited with code ${code}`);
});
Expand Down