From c99c095f991024052fcf8d32d230ce448edc2d81 Mon Sep 17 00:00:00 2001 From: Olivier Hainque Date: Fri, 6 Apr 2007 11:15:36 +0200 Subject: adaint.c: 2007-04-06 Olivier Hainque * adaint.c: (convert_addresses): Adjust prototype and dummy definition to expect an extra file_name argument. * gmem.c (__gnat_convert_addresses): Wrapper to convert_addresses, filling the now expected file_name argument with the appropriate argv[0] expansion. (__gnat_gmem_a2l_initialize, __gnat_gmem_read_next_frame): Use it. (tracebk): Array of void * instead of char *, corresponding to what convert_addresses expects. (exename): New static global, to hold the executable file name to be used in all convert_addresses invocations. (gmem_read_backtrace, __gnat_gmem_symbolic): Account for tracebk type change. (__gnat_gmem_a2l_initialize): Resolve exename. (__gnat_convert_addresses): Use exename as the convert_addresses file_name argument. * g-trasym.adb (Symbolic_Traceback): Adjust signature of imported "convert_addresses", now expecting a filename argument. Import the necessary entities to compute the filename to use and pass it to convert_addresses. From-SVN: r123544 --- gcc/ada/gmem.c | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) (limited to 'gcc/ada/gmem.c') diff --git a/gcc/ada/gmem.c b/gcc/ada/gmem.c index 74299ad..e45e12c 100644 --- a/gcc/ada/gmem.c +++ b/gcc/ada/gmem.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 2000-2003 Free Software Foundation, Inc. * + * Copyright (C) 2000-2006, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -54,7 +54,7 @@ static FILE *gmemfile; /* tb_len is the number of call level supported by this module */ #define tb_len 200 -static char * tracebk [tb_len]; +static void * tracebk [tb_len]; static int cur_tb_len, cur_tb_pos; #define LOG_EOF '*' @@ -67,8 +67,34 @@ struct struct_storage_elmt { size_t Size; }; -extern void -convert_addresses (char *addrs[], int n_addr, void *buf, int *len); +static void +__gnat_convert_addresses (void *addrs[], int n_addrs, void *buf, int *len); +/* Place in BUF a string representing the symbolic translation of N_ADDRS raw + addresses provided in ADDRS. LEN is filled with the result length. + + This is a GNAT specific interface to the libaddr2line convert_addresses + routine. The latter examines debug info from a provided executable file + name to perform the translation into symbolic form of an input sequence of + raw binary addresses. It attempts to open the file from the provided name + "as is", so an an absolute path must be provided to ensure the file is + always found. We compute this name once, at initialization time. */ + +static const char * exename = 0; + +extern void convert_addresses (const char * , void *[], int, void *, int *); +extern char *__gnat_locate_exec_on_path (char *); +/* ??? Both of these extern functions are prototyped in adaint.h, which + also refers to "time_t" hence needs complex extra header inclusions to + be satisfied on every target. */ + +static void +__gnat_convert_addresses (void *addrs[], int n_addrs, void *buf, int *len) +{ + if (exename != 0) + convert_addresses (exename, addrs, n_addrs, buf, len); + else + *len = 0; +} /* reads backtrace information from gmemfile placing them in tracebk array. cur_tb_len is the size of this array @@ -78,7 +104,7 @@ static void gmem_read_backtrace (void) { fread (&cur_tb_len, sizeof (int), 1, gmemfile); - fread (tracebk, sizeof (char *), cur_tb_len, gmemfile); + fread (tracebk, sizeof (void *), cur_tb_len, gmemfile); cur_tb_pos = 0; } @@ -106,14 +132,11 @@ int __gnat_gmem_initialize (char *dumpname) /* initialize addr2line library */ -void __gnat_gmem_a2l_initialize (char *exename) +void __gnat_gmem_a2l_initialize (char *exearg) { - extern char **gnat_argv; - char s [100]; - int l; - - gnat_argv [0] = exename; - convert_addresses (tracebk, 1, s, &l); + /* Resolve the executable filename to use in later invocations of + the libaddr2line symbolization service. */ + exename = __gnat_locate_exec_on_path (exearg); } /* Read next allocation of deallocation information from the GMEM file and @@ -172,8 +195,7 @@ void __gnat_gmem_read_next_frame (void** addr) void __gnat_gmem_symbolic (void * addr, char* buf, int* length) { - char* addresses [] = { (char*)addr }; - extern char** gnat_argv; + void * addresses [] = { addr }; - convert_addresses (addresses, 1, buf, length); + __gnat_convert_addresses (addresses, 1, buf, length); } -- cgit v1.1