summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/trace_profile.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/runtime/trace_profile.cc b/runtime/trace_profile.cc
index 58927d8948..26f80ad60d 100644
--- a/runtime/trace_profile.cc
+++ b/runtime/trace_profile.cc
@@ -58,7 +58,7 @@ static constexpr size_t kProfileMagicValue = 0x4C4F4D54;
// TODO(mythria): 10 is a randomly chosen value. Tune it if required.
static constexpr size_t kBufSizeForEncodedData = kMinBufSizeForEncodedData * 10;
-static constexpr size_t kAlwaysOnTraceHeaderSize = 8;
+static constexpr size_t kAlwaysOnTraceHeaderSize = 12;
bool TraceProfiler::profile_in_progress_ = false;
@@ -198,7 +198,7 @@ void RecordMethodsOnThreadStack(Thread* thread, uintptr_t* method_trace_buffer)
// Record a placeholder method exit event into the buffer so we record method exits for the
// methods that are currently on stack.
method_trace_buffer[index] = 0x1;
- thread->SetMethodTraceBufferCurrentEntry(index);
+ thread->SetMethodTraceBuffer(method_trace_buffer, index);
}
// Records the thread and method info.
@@ -236,7 +236,6 @@ static class LongRunningMethodsTraceStartCheckpoint final : public Closure {
// Record methods that are currently on stack.
RecordMethodsOnThreadStack(thread, buffer);
thread->UpdateTlsLowOverheadTraceEntrypoints(LowOverheadTraceType::kLongRunningMethods);
- thread->SetMethodTraceBuffer(buffer, kAlwaysOnTraceBufSize);
}
} long_running_methods_checkpoint_;
@@ -509,12 +508,17 @@ size_t TraceProfiler::DumpLongRunningMethodBuffer(uint32_t thread_id,
size_t end_index = end_trace_entries - method_trace_entries;
for (size_t i = kAlwaysOnTraceBufSize - 1; i >= end_index;) {
uintptr_t event = method_trace_entries[i--];
+ if (event == 0x1) {
+ // This is a placeholder event. Ignore this event.
+ continue;
+ }
+
bool is_method_exit = event & 0x1;
uint64_t timestamp_action_encoding;
uintptr_t method_ptr;
if (is_method_exit) {
// Method exit. We only have timestamp here.
- timestamp_action_encoding = event & ~1;
+ timestamp_action_encoding = event;
} else {
// method entry
method_ptr = event;
@@ -522,26 +526,29 @@ size_t TraceProfiler::DumpLongRunningMethodBuffer(uint32_t thread_id,
}
int64_t timestamp_action_diff = timestamp_action_encoding - prev_timestamp_action_encoding;
- int64_t method_diff;
+ curr_buffer_ptr = EncodeSignedLeb128(curr_buffer_ptr, timestamp_action_diff);
+ prev_timestamp_action_encoding = timestamp_action_encoding;
+
if (!is_method_exit) {
- method_diff = method_ptr - prev_method_ptr;
+ int64_t method_diff = method_ptr - prev_method_ptr;
ArtMethod* method = reinterpret_cast<ArtMethod*>(method_ptr);
methods.insert(method);
prev_method_ptr = method_ptr;
curr_buffer_ptr = EncodeSignedLeb128(curr_buffer_ptr, method_diff);
}
- curr_buffer_ptr = EncodeSignedLeb128(curr_buffer_ptr, timestamp_action_diff);
num_records++;
- prev_timestamp_action_encoding = timestamp_action_encoding;
}
// Fill in header information:
// 1 byte of header identifier
// 4 bytes of thread_id
// 3 bytes of number of records
+ // 4 bytes the size of the data
buffer[0] = kEntryHeaderV2;
Append4LE(buffer + 1, thread_id);
Append3LE(buffer + 5, num_records);
+ size_t size = curr_buffer_ptr - buffer;
+ Append4LE(buffer + 8, size - kAlwaysOnTraceHeaderSize);
return curr_buffer_ptr - buffer;
}