[pypy-commit] pypy vmprof: Rewrite addresses to point to the start of JIT code
fijal
noreply at buildbot.pypy.org
Wed Apr 1 14:16:24 CEST 2015
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: vmprof
Changeset: r76672:a3d990e5c7d4
Date: 2015-04-01 14:16 +0200
http://bitbucket.org/pypy/pypy/changeset/a3d990e5c7d4/
Log: Rewrite addresses to point to the start of JIT code
diff --git a/pypy/module/_vmprof/src/get_custom_offset.c b/pypy/module/_vmprof/src/get_custom_offset.c
--- a/pypy/module/_vmprof/src/get_custom_offset.c
+++ b/pypy/module/_vmprof/src/get_custom_offset.c
@@ -13,31 +13,37 @@
int custom_sanity_check()
{
- return !pypy_codemap_currently_invalid;
+ return !pypy_codemap_currently_invalid;
}
static ptrdiff_t vmprof_unw_get_custom_offset(void* ip, unw_cursor_t *cp) {
- intptr_t ip_l = (intptr_t)ip;
- return pypy_jit_stack_depth_at_loc(ip_l);
+ intptr_t ip_l = (intptr_t)ip;
+ return pypy_jit_stack_depth_at_loc(ip_l);
}
static long vmprof_write_header_for_jit_addr(void **result, long n,
- void *ip, int max_depth)
+ void *ip, int max_depth)
{
- void *codemap;
- long current_pos = 0;
- intptr_t id;
- intptr_t addr = (intptr_t)ip;
+ void *codemap;
+ long current_pos = 0;
+ intptr_t id;
+ long start_addr = 0;
+ intptr_t addr = (intptr_t)ip;
- codemap = pypy_find_codemap_at_addr(addr);
- if (codemap == NULL)
- return n;
+ codemap = pypy_find_codemap_at_addr(addr, &start_addr);
+ if (codemap == NULL)
+ // not a jit code at all
+ return n;
- while (n < max_depth) {
- id = pypy_yield_codemap_at_addr(codemap, addr, ¤t_pos);
- if (id == 0)
- break;
- result[n++] = (void *)id;
- }
- return n;
+ // modify the last entry to point to start address and not the random one
+ // in the middle
+ result[n - 1] = (void*)start_addr;
+ while (n < max_depth) {
+ id = pypy_yield_codemap_at_addr(codemap, addr, ¤t_pos);
+ if (id == 0)
+ // finish
+ break;
+ result[n++] = (void *)id;
+ }
+ return n;
}
diff --git a/rpython/jit/backend/llsupport/src/codemap.c b/rpython/jit/backend/llsupport/src/codemap.c
--- a/rpython/jit/backend/llsupport/src/codemap.c
+++ b/rpython/jit/backend/llsupport/src/codemap.c
@@ -76,12 +76,13 @@
/*** interface used from pypy/module/_vmprof ***/
RPY_EXTERN
-void *pypy_find_codemap_at_addr(long addr)
+void *pypy_find_codemap_at_addr(long addr, long* start_addr)
{
skipnode_t *codemap = skiplist_search(&jit_codemap_head, addr);
codemap_data_t *data;
uintptr_t rel_addr;
+ *start_addr = 0;
if (codemap == &jit_codemap_head)
return NULL;
@@ -90,6 +91,7 @@
if (rel_addr >= data->machine_code_size)
return NULL;
+ *start_addr = (long)codemap->key;
return (void *)codemap;
}
More information about the pypy-commit
mailing list