Skip to content

Commit 2ae8233

Browse files
committed
save memory area addresses for tracing
1 parent 9acfbca commit 2ae8233

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

accel/tcg/tcg-runtime-sym.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,4 +660,4 @@ void HELPER(sym_notify_block)(uint64_t block_id)
660660
void HELPER(sym_collect_garbage)(void)
661661
{
662662
_sym_collect_garbage();
663-
}
663+
}

linux-user/main.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,34 @@ static int parse_args(int argc, char **argv)
594594
return optind;
595595
}
596596

597+
598+
static void save_memory_areas(void * env, struct image_info * info){
599+
FILE* f = fopen("/tmp/symqemu_addresses.json", "w");
600+
if (f == NULL) {
601+
printf("Error opening addresses file\n");
602+
return;
603+
}
604+
605+
const char *format = "{\"name\":\"%s\",\"address\":%lu},\n";
606+
fprintf(f, "[\n");
607+
608+
for(TCGTemp* temp = tcg_ctx->temps; temp != tcg_ctx->temps + tcg_ctx->nb_globals; temp++){
609+
if (temp->mem_allocated) {
610+
// we do not support memory allocated temps whose base is not env
611+
tcg_debug_assert(!temp->indirect_reg);
612+
void * temp_mem_address = env + temp->mem_offset;
613+
fprintf(f, format, temp->name, temp_mem_address);
614+
}
615+
}
616+
fprintf(f, format, "xmm_t0", env + offsetof(CPUX86State, xmm_t0));
617+
618+
fprintf(f, format, "stack", info->start_stack);
619+
620+
fseek(f, -2, SEEK_CUR);
621+
fprintf(f, "\n]");
622+
fclose(f);
623+
}
624+
597625
int main(int argc, char **argv, char **envp)
598626
{
599627
struct target_pt_regs regs1, *regs = &regs1;
@@ -840,6 +868,9 @@ int main(int argc, char **argv, char **envp)
840868
}
841869
gdb_handlesig(cpu, 0);
842870
}
871+
872+
save_memory_areas((void *) env, info);
873+
843874
cpu_loop(env);
844875
/* never exits */
845876
return 0;

linux-user/syscall.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@
8787
#include <linux/kd.h>
8888
#include <linux/mtio.h>
8989
#include <linux/fs.h>
90+
91+
#define SymExpr void*
92+
#include "RuntimeCommon.h"
93+
9094
#if defined(CONFIG_FIEMAP)
9195
#include <linux/fiemap.h>
9296
#endif
@@ -9264,6 +9268,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
92649268
/* new thread calls */
92659269
case TARGET_NR_exit_group:
92669270
preexit_cleanup(cpu_env, arg1);
9271+
_sym_finalize_tracing();
92679272
return get_errno(exit_group(arg1));
92689273
#endif
92699274
case TARGET_NR_setdomainname:

0 commit comments

Comments
 (0)