Add trace thread mask.

Makes seeing only thread 1 easier.
This commit is contained in:
Ben Vanik 2013-10-06 14:35:03 -07:00
parent 1fecb95512
commit 74692232c9
3 changed files with 31 additions and 4 deletions

View File

@ -18,6 +18,7 @@ DECLARE_bool(trace_registers);
DECLARE_bool(trace_branches); DECLARE_bool(trace_branches);
DECLARE_bool(trace_user_calls); DECLARE_bool(trace_user_calls);
DECLARE_bool(trace_kernel_calls); DECLARE_bool(trace_kernel_calls);
DECLARE_uint64(trace_thread_mask);
DECLARE_string(load_module_map); DECLARE_string(load_module_map);

View File

@ -21,6 +21,8 @@ DEFINE_bool(trace_user_calls, false,
"Trace all user function calls."); "Trace all user function calls.");
DEFINE_bool(trace_kernel_calls, false, DEFINE_bool(trace_kernel_calls, false,
"Trace all kernel function calls."); "Trace all kernel function calls.");
DEFINE_uint64(trace_thread_mask, -1,
"Trace threads with IDs in the mask, or -1 for all.");
// Debugging: // Debugging:

View File

@ -77,6 +77,10 @@ void _cdecl XeTraceKernelCall(
xe_ppc_state_t* state, uint64_t cia, uint64_t call_ia, xe_ppc_state_t* state, uint64_t cia, uint64_t call_ia,
KernelExport* kernel_export) { KernelExport* kernel_export) {
uint32_t thread_id = state->thread_state->thread_id(); uint32_t thread_id = state->thread_state->thread_id();
if (!((1ull << thread_id) & FLAGS_trace_thread_mask)) {
return;
}
xe_log_line("", thread_id, "XeTraceKernelCall", 't', xe_log_line("", thread_id, "XeTraceKernelCall", 't',
"KERNEL CALL: %.8X -> k.%.8X (%s)%s", "KERNEL CALL: %.8X -> k.%.8X (%s)%s",
(uint32_t)call_ia - 4, (uint32_t)cia, (uint32_t)call_ia - 4, (uint32_t)cia,
@ -89,6 +93,10 @@ void _cdecl XeTraceUserCall(
xe_ppc_state_t* state, uint64_t cia, uint64_t call_ia, xe_ppc_state_t* state, uint64_t cia, uint64_t call_ia,
FunctionSymbol* fn) { FunctionSymbol* fn) {
uint32_t thread_id = state->thread_state->thread_id(); uint32_t thread_id = state->thread_state->thread_id();
if (!((1ull << thread_id) & FLAGS_trace_thread_mask)) {
return;
}
xe_log_line("", thread_id, "XeTraceUserCall", 't', xe_log_line("", thread_id, "XeTraceUserCall", 't',
"USER CALL %.8X -> u.%.8X (%s)", "USER CALL %.8X -> u.%.8X (%s)",
(uint32_t)call_ia - 4, (uint32_t)cia, fn->name()); (uint32_t)call_ia - 4, (uint32_t)cia, fn->name());
@ -96,6 +104,11 @@ void _cdecl XeTraceUserCall(
void _cdecl XeTraceBranch( void _cdecl XeTraceBranch(
xe_ppc_state_t* state, uint64_t cia, uint64_t target_ia) { xe_ppc_state_t* state, uint64_t cia, uint64_t target_ia) {
uint32_t thread_id = state->thread_state->thread_id();
if (!((1ull << thread_id) & FLAGS_trace_thread_mask)) {
return;
}
switch (target_ia) { switch (target_ia) {
case kXEPPCRegLR: case kXEPPCRegLR:
target_ia = state->lr; target_ia = state->lr;
@ -105,7 +118,6 @@ void _cdecl XeTraceBranch(
break; break;
} }
uint32_t thread_id = state->thread_state->thread_id();
xe_log_line("", thread_id, "XeTraceBranch", 't', xe_log_line("", thread_id, "XeTraceBranch", 't',
"BRANCH %.8X -> b.%.8X", "BRANCH %.8X -> b.%.8X",
(uint32_t)cia, (uint32_t)target_ia); (uint32_t)cia, (uint32_t)target_ia);
@ -118,6 +130,11 @@ void _cdecl XeTraceFPR(
buffer[0] = 0; buffer[0] = 0;
int offset = 0; int offset = 0;
uint32_t thread_id = state->thread_state->thread_id();
if (!((1ull << thread_id) & FLAGS_trace_thread_mask)) {
return;
}
offset += xesnprintfa(buffer + offset, XECOUNT(buffer) - offset, offset += xesnprintfa(buffer + offset, XECOUNT(buffer) - offset,
"%.8X:", state->cia); "%.8X:", state->cia);
@ -140,7 +157,6 @@ void _cdecl XeTraceFPR(
"\nf%.2d = %e", fpr4, state->f[fpr4]); "\nf%.2d = %e", fpr4, state->f[fpr4]);
} }
uint32_t thread_id = state->thread_state->thread_id();
xe_log_line("", thread_id, "XeTraceFPR", 't', buffer); xe_log_line("", thread_id, "XeTraceFPR", 't', buffer);
} }
@ -151,6 +167,11 @@ void _cdecl XeTraceVR(
buffer[0] = 0; buffer[0] = 0;
int offset = 0; int offset = 0;
uint32_t thread_id = state->thread_state->thread_id();
if (!((1ull << thread_id) & FLAGS_trace_thread_mask)) {
return;
}
offset += xesnprintfa(buffer + offset, XECOUNT(buffer) - offset, offset += xesnprintfa(buffer + offset, XECOUNT(buffer) - offset,
"%.8X:", state->cia); "%.8X:", state->cia);
@ -183,7 +204,6 @@ void _cdecl XeTraceVR(
state->v[vr4].x, state->v[vr4].y, state->v[vr4].z, state->v[vr4].w); state->v[vr4].x, state->v[vr4].y, state->v[vr4].z, state->v[vr4].w);
} }
uint32_t thread_id = state->thread_state->thread_id();
xe_log_line("", thread_id, "XeTraceVR", 't', buffer); xe_log_line("", thread_id, "XeTraceVR", 't', buffer);
} }
@ -193,6 +213,11 @@ void _cdecl XeTraceInstruction(
buffer[0] = 0; buffer[0] = 0;
int offset = 0; int offset = 0;
uint32_t thread_id = state->thread_state->thread_id();
if (!((1ull << thread_id) & FLAGS_trace_thread_mask)) {
return;
}
if (FLAGS_trace_registers) { if (FLAGS_trace_registers) {
offset += xesnprintfa(buffer + offset, XECOUNT(buffer) - offset, offset += xesnprintfa(buffer + offset, XECOUNT(buffer) - offset,
"\n" "\n"
@ -238,7 +263,6 @@ void _cdecl XeTraceInstruction(
i.type ? i.type->name : "<unknown>"); i.type ? i.type->name : "<unknown>");
} }
uint32_t thread_id = state->thread_state->thread_id();
xe_log_line("", thread_id, "XeTraceInstruction", 't', buffer); xe_log_line("", thread_id, "XeTraceInstruction", 't', buffer);
// if (cia == 0x82012074) { // if (cia == 0x82012074) {