Chromium Code Reviews| Index: native_client_sdk/src/libraries/xray/xray.c |
| =================================================================== |
| --- native_client_sdk/src/libraries/xray/xray.c (revision 208986) |
| +++ native_client_sdk/src/libraries/xray/xray.c (working copy) |
| @@ -19,9 +19,20 @@ |
| #if defined(XRAY) |
| -#define RDTSC(_x) __asm__ __volatile__ ("rdtsc" : "=A" (_x)); |
| #define FORCE_INLINE __attribute__((always_inline)) |
| +#if defined(__amd64__) |
| +FORCE_INLINE uint64_t RDTSC64() { |
| + uint64_t a, d; |
| + __asm__ __volatile__("rdtsc" : "=a" (a), "=d" (d)); |
| + return ((uint64_t)a) | (((uint64_t)d) << 32); |
| +} |
| +#define RDTSC(_x) _x = RDTSC64() |
| +#else |
| +#define RDTSC(_x) __asm__ __volatile__ ("rdtsc" : "=A" (_x)); |
| +#endif |
| + |
| + |
| /* Use a TLS variable for cheap thread uid. */ |
| volatile __thread int g_xray_thread_id; |
| @@ -591,7 +602,8 @@ |
| /* Dumps the trace report for a given frame. */ |
| -void XRayTraceReport(FILE* f, int frame, char* label, float cutoff) { |
| +void XRayTraceReport(FILE* f, int frame, char* label, |
| + float percent_cutoff, int ticks_cutoff) { |
| int index; |
| int start; |
| int end; |
| @@ -626,7 +638,7 @@ |
| uint32_t ticks = (e->ticks); |
| uint32_t annotation_index = (e->annotation_index); |
| float percent = 100.0f * (float)ticks / total; |
| - if (percent >= cutoff) { |
| + if (percent >= percent_cutoff && ticks >= ticks_cutoff) { |
| if (depth > 250) bad_depth++; |
|
bradn
2013/06/27 23:01:24
Might be nice to give this (250) a name and move u
nfullagar1
2013/06/27 23:41:55
This code isn't needed, I'll remove it.
|
| struct XRaySymbol* symbol; |
| symbol = XRaySymbolTableLookup(g_xray.symbols, addr); |
| @@ -724,11 +736,12 @@ |
| /* Dump a frame report followed by trace report(s) for each frame. */ |
| -void XRayReport(FILE* f, float cutoff) { |
| +void XRayReport(FILE* f, float percent_cutoff, int ticks_cutoff) { |
| int head; |
| int index; |
| int counter = 0; |
| - fprintf(f, "Number of symbols: %d\n", XRaySymbolCount(g_xray.symbols)); |
| + if (g_xray.symbols) |
| + fprintf(f, "Number of symbols: %d\n", XRaySymbolCount(g_xray.symbols)); |
| XRayFrameReport(f); |
| fprintf(f, "\n"); |
| head = g_xray.frame.head; |
| @@ -737,8 +750,9 @@ |
| char label[XRAY_MAX_LABEL]; |
| fprintf(f, "\n"); |
| XRayFrameMakeLabel(counter, label); |
| - XRayTraceReport(f, index, label, cutoff); |
| + XRayTraceReport(f, index, label, percent_cutoff, ticks_cutoff); |
| index = XRayFrameNext(index); |
| + |
| ++counter; |
| } |
| fprintf(f, |
| @@ -750,11 +764,13 @@ |
| /* Write a profile report to text file. */ |
| -void XRaySaveReport(const char* filename, float cutoff) { |
| +void XRaySaveReport(const char* filename, |
| + float percent_cutoff, |
| + int ticks_cutoff) { |
| FILE* f; |
| f = fopen(filename, "wt"); |
| if (NULL != f) { |
| - XRayReport(f, cutoff); |
| + XRayReport(f, percent_cutoff, ticks_cutoff); |
| fclose(f); |
| } |
| } |
| @@ -788,10 +804,9 @@ |
| XRayReset(); |
| /* Mapfile is optional; we don't need it for captures, only for reports. */ |
| - if (NULL != mapfilename) { |
| - g_xray.symbols = XRaySymbolTableCreate(XRAY_DEFAULT_SYMBOL_TABLE_SIZE); |
| + g_xray.symbols = XRaySymbolTableCreate(XRAY_DEFAULT_SYMBOL_TABLE_SIZE); |
| + if (NULL != mapfilename) |
| XRaySymbolTableParseMapfile(g_xray.symbols, mapfilename); |
| - } |
| } |