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

Side by Side Diff: native_client_sdk/src/libraries/xray/symtable.c

Issue 19409003: Update Xray for PNaCl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: the real changes 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 unified diff | Download patch
OLDNEW
1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* XRay symbol table */ 6 /* XRay symbol table */
7 7
8 #define _GNU_SOURCE 8 #define _GNU_SOURCE
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
11 #include <stdlib.h> 11 #include <stdlib.h>
12 #include <string.h> 12 #include <string.h>
13 13
14 #if defined(__GLIBC__) 14 #if defined(__GLIBC__)
15 #include <dlfcn.h> 15 #include <dlfcn.h>
16 #endif 16 #endif
17 17
18 #include "xray/xray_priv.h" 18 #include "xray/xray_priv.h"
19 #define PNACL_STRING_OFFSET (0x10000000)
nfullagar1 2013/07/18 23:49:42 one thought (for another CL...) is to have a known
19 20
20 #if defined(XRAY) 21 #if defined(XRAY)
21 22
22 bool g_symtable_debug = false; 23 bool g_symtable_debug = false;
23 24
24 struct XRayFrameInfo { 25 struct XRayFrameInfo {
25 int times_called; 26 int times_called;
26 int total_ticks; 27 int total_ticks;
27 }; 28 };
28 29
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 printf("adding symbol %s\n", recorded_name); 139 printf("adding symbol %s\n", recorded_name);
139 /* construct a symbol and put it in the symbol table */ 140 /* construct a symbol and put it in the symbol table */
140 symbol = XRaySymbolCreate(symtab->symbol_pool, recorded_name); 141 symbol = XRaySymbolCreate(symtab->symbol_pool, recorded_name);
141 return XRaySymbolTableAdd(symtab, symbol, addr); 142 return XRaySymbolTableAdd(symtab, symbol, addr);
142 } 143 }
143 144
144 struct XRaySymbol* XRaySymbolTableLookup(struct XRaySymbolTable* symtab, 145 struct XRaySymbol* XRaySymbolTableLookup(struct XRaySymbolTable* symtab,
145 uint32_t addr) { 146 uint32_t addr) {
146 void *x = XRayHashTableLookup(symtab->hash_table, addr); 147 void *x = XRayHashTableLookup(symtab->hash_table, addr);
147 struct XRaySymbol* r = (struct XRaySymbol*)x; 148 struct XRaySymbol* r = (struct XRaySymbol*)x;
149
150 #if defined(__pnacl__)
151 if (r == NULL) {
152 /* Addresses are trimed to 24 bits for internal storage, so we need to
153 * add this offset back in order to get the real address.
154 */
155 addr |= PNACL_STRING_OFFSET;
156 const char* name = (const char*)addr;
157 struct XRaySymbol* symbol = XRaySymbolCreate(symtab->symbol_pool, name);
158 r = XRaySymbolTableAdd(symtab, symbol, addr);
159 }
160 #endif
161
148 #if defined(__GLIBC__) 162 #if defined(__GLIBC__)
149 if (r == NULL) { 163 if (r == NULL) {
150 Dl_info info; 164 Dl_info info;
151 if (dladdr((const void*)addr, &info) != 0) 165 if (dladdr((const void*)addr, &info) != 0)
152 if (info.dli_sname) 166 if (info.dli_sname)
153 r = XRaySymbolTableAddByName(symtab, info.dli_sname, addr); 167 r = XRaySymbolTableAddByName(symtab, info.dli_sname, addr);
154 } 168 }
155 #endif 169 #endif
156 return r; 170 return r;
157 } 171 }
(...skipping 20 matching lines...) Expand all
178 /* Frees a symbol table. */ 192 /* Frees a symbol table. */
179 void XRaySymbolTableFree(struct XRaySymbolTable* symtab) { 193 void XRaySymbolTableFree(struct XRaySymbolTable* symtab) {
180 XRayStringPoolFree(symtab->string_pool); 194 XRayStringPoolFree(symtab->string_pool);
181 XRaySymbolPoolFree(symtab->symbol_pool); 195 XRaySymbolPoolFree(symtab->symbol_pool);
182 XRayHashTableFree(symtab->hash_table); 196 XRayHashTableFree(symtab->hash_table);
183 symtab->num_symbols = 0; 197 symtab->num_symbols = 0;
184 XRayFree(symtab); 198 XRayFree(symtab);
185 } 199 }
186 200
187 #endif /* XRAY */ 201 #endif /* XRAY */
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/xray/report.c ('k') | native_client_sdk/src/libraries/xray/xray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698