Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: native_client_sdk/src/libraries/xray/xray.c

Issue 19409003: Update Xray for PNaCl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge __x_profile funcs and add comments to address mask Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/xray/xray.c
diff --git a/native_client_sdk/src/libraries/xray/xray.c b/native_client_sdk/src/libraries/xray/xray.c
index 5cfa42a275abaf70803b2133eeb852e408068ef2..76664c464a255f95ab634e20c487520c31bb3a08 100644
--- a/native_client_sdk/src/libraries/xray/xray.c
+++ b/native_client_sdk/src/libraries/xray/xray.c
@@ -40,9 +40,9 @@ FORCE_INLINE uint64_t GTOD() {
#define GTSC(_x) _x = GTOD();
#endif
-
/* Use a TLS variable for cheap thread uid. */
__thread struct XRayTraceCapture* g_xray_capture = NULL;
+__thread int g_xray_thread_id_dummy = 0;
nfullagar1 2013/07/18 18:21:06 nit: another word besides dummy
grosse 2013/07/18 20:45:37 Done.
struct XRayTraceStackEntry {
@@ -62,6 +62,11 @@ struct XRayTraceFrameEntry {
uint64_t total_ticks;
int annotation_count;
bool valid;
+
+#ifndef XRAY_DISABLE_BROWSER_INTEGRATION
+ struct XRayTimestampPair start_time;
+ struct XRayTimestampPair end_time;
+#endif
};
@@ -93,6 +98,10 @@ struct XRayTraceCapture {
uint32_t guard3;
struct XRayTraceBufferEntry* buffer;
struct XRayTraceFrame frame;
+
+#ifndef XRAY_DISABLE_BROWSER_INTEGRATION
+ int32_t thread_id;
+#endif
} XRAY_ALIGN64;
@@ -100,10 +109,15 @@ struct XRayTraceCapture {
extern "C" {
#endif
-XRAY_NO_INSTRUMENT void __cyg_profile_func_enter(void* this_fn,
- void* call_site);
-XRAY_NO_INSTRUMENT void __cyg_profile_func_exit(void* this_fn,
- void* call_site);
+#if defined(__pnacl__)
+XRAY_NO_INSTRUMENT void __pnacl_profile_func_enter(const char* fname);
+XRAY_NO_INSTRUMENT void __pnacl_profile_func_exit(const char* fname);
+#else
+XRAY_NO_INSTRUMENT void __cyg_profile_func_enter(
+ void* this_fn, void* call_site);
+XRAY_NO_INSTRUMENT void __cyg_profile_func_exit(void* this_fn, void* call_site);
+#endif
+
XRAY_NO_INSTRUMENT void __xray_profile_append_annotation(
struct XRayTraceCapture* capture,
struct XRayTraceStackEntry* se,
@@ -113,7 +127,6 @@ XRAY_NO_INSTRUMENT void __xray_profile_append_annotation(
}
#endif
-
/* Asserts that the guard values haven't changed. */
void XRayCheckGuards(struct XRayTraceCapture* capture) {
assert(capture->guard0 == XRAY_GUARD_VALUE_0x12345678);
@@ -303,11 +316,14 @@ void XRayFree(void* data) {
}
-
/* Main profile capture function that is called at the start */
/* of every instrumented function. This function is implicitly */
/* called when code is compilied with the -finstrument-functions option */
+#if defined(__pnacl__)
+void __pnacl_profile_func_enter(const char* this_fn) {
+#else
void __cyg_profile_func_enter(void* this_fn, void* call_site) {
+#endif
struct XRayTraceCapture* capture = g_xray_capture;
if (capture && capture->recording) {
uint32_t depth = capture->stack_depth;
@@ -329,7 +345,11 @@ void __cyg_profile_func_enter(void* this_fn, void* call_site) {
/* Main profile capture function that is called at the exit of */
/* every instrumented function. This function is implicity called */
/* when the code is compiled with the -finstrument-functions option */
+#if defined(__pnacl__)
+void __pnacl_profile_func_exit(const char* this_fn) {
+#else
void __cyg_profile_func_exit(void* this_fn, void* call_site) {
+#endif
struct XRayTraceCapture* capture = g_xray_capture;
if (capture && capture->recording) {
--capture->stack_depth;
@@ -350,6 +370,22 @@ void __cyg_profile_func_exit(void* this_fn, void* call_site) {
}
}
+#ifndef XRAY_DISABLE_BROWSER_INTEGRATION
+void XRayGetTSC(uint64_t* tsc) {
+ GTSC(*tsc);
+}
+
+int32_t XRayGetSavedThreadID(struct XRayTraceCapture* capture) {
+ return capture->thread_id;
+}
+
+struct XRayTimestampPair* XRayGetTimestamp(
nfullagar1 2013/07/18 18:21:07 Not sure I agree here returning a pointer into the
grosse 2013/07/18 20:45:37 Done.
+ struct XRayTraceCapture* capture, int frame, bool end) {
+
+ struct XRayTraceFrameEntry* entry = &(capture->frame.entry[frame]);
+ return end ? &entry->end_time : &entry->start_time;
+}
+#endif
/* Special case appending annotation string to trace buffer */
/* this function should only ever be called from __cyg_profile_func_exit() */
@@ -573,6 +609,11 @@ void XRayStartFrame(struct XRayTraceCapture* capture) {
capture->recording = true;
GTSC(capture->frame.entry[i].start_tsc);
g_xray_capture = capture;
+
+#ifndef XRAY_DISABLE_BROWSER_INTEGRATION
+ capture->frame.entry[i].start_time = XRayGenerateTimestampsNow();
+#endif /* XRAY_DISABLE_BROWSER_INTEGRATION */
+
}
@@ -612,6 +653,10 @@ void XRayEndFrame(struct XRayTraceCapture* capture) {
XRayCheckGuards(capture);
}
g_xray_capture = NULL;
+
+#ifndef XRAY_DISABLE_BROWSER_INTEGRATION
+ capture->frame.entry[i].end_time = XRayGenerateTimestampsNow();
+#endif /* XRAY_DISABLE_BROWSER_INTEGRATION */
}
@@ -699,6 +744,11 @@ struct XRayTraceCapture* XRayInit(int stack_depth,
if (NULL != mapfilename)
XRaySymbolTableParseMapfile(capture->symbols, mapfilename);
+#ifndef XRAY_DISABLE_BROWSER_INTEGRATION
+ /* Use address of a thread local variable as for our fake thread id. */
nfullagar1 2013/07/18 18:21:07 above comment: re-word '...variable as for...'
grosse 2013/07/18 20:45:37 Done.
+ capture->thread_id = (int32_t)(&g_xray_thread_id_dummy);
+#endif
+
return capture;
}

Powered by Google App Engine
This is Rietveld 408576698