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

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: 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 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)
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
nfullagar1 2013/07/18 18:21:06 remove blank line
grosse 2013/07/18 20:45:37 Done.
156 addr |= PNACL_STRING_OFFSET;
157 const char* name = (const char*)addr;
158 struct XRaySymbol* symbol = XRaySymbolCreate(symtab->symbol_pool, name);
159 r = XRaySymbolTableAdd(symtab, symbol, addr);
160 }
161 #endif
162
148 #if defined(__GLIBC__) 163 #if defined(__GLIBC__)
149 if (r == NULL) { 164 if (r == NULL) {
150 Dl_info info; 165 Dl_info info;
151 if (dladdr((const void*)addr, &info) != 0) 166 if (dladdr((const void*)addr, &info) != 0)
152 if (info.dli_sname) 167 if (info.dli_sname)
153 r = XRaySymbolTableAddByName(symtab, info.dli_sname, addr); 168 r = XRaySymbolTableAddByName(symtab, info.dli_sname, addr);
154 } 169 }
155 #endif 170 #endif
156 return r; 171 return r;
157 } 172 }
(...skipping 20 matching lines...) Expand all
178 /* Frees a symbol table. */ 193 /* Frees a symbol table. */
179 void XRaySymbolTableFree(struct XRaySymbolTable* symtab) { 194 void XRaySymbolTableFree(struct XRaySymbolTable* symtab) {
180 XRayStringPoolFree(symtab->string_pool); 195 XRayStringPoolFree(symtab->string_pool);
181 XRaySymbolPoolFree(symtab->symbol_pool); 196 XRaySymbolPoolFree(symtab->symbol_pool);
182 XRayHashTableFree(symtab->hash_table); 197 XRayHashTableFree(symtab->hash_table);
183 symtab->num_symbols = 0; 198 symtab->num_symbols = 0;
184 XRayFree(symtab); 199 XRayFree(symtab);
185 } 200 }
186 201
187 #endif /* XRAY */ 202 #endif /* XRAY */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698