aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/adaint.c
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2013-01-02 12:06:15 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2013-01-02 12:06:15 +0100
commitef7c5fa919b358f10946c832007a488c22753bb9 (patch)
tree0c40dcc14b5b2a9a02d9d7e8d295aa78b373e396 /gcc/ada/adaint.c
parente9f80612564876fc089ae96504e0ceaa0c33e0e8 (diff)
downloadgcc-ef7c5fa919b358f10946c832007a488c22753bb9.zip
gcc-ef7c5fa919b358f10946c832007a488c22753bb9.tar.gz
gcc-ef7c5fa919b358f10946c832007a488c22753bb9.tar.bz2
[multiple changes]
2013-01-02 Robert Dewar <dewar@adacore.com> * gnat1drv.adb, targparm.adb, targparm.ads: Minor name change: add On_Target to Atomic_Sync_Default. 2013-01-02 Robert Dewar <dewar@adacore.com> * sem_warn.adb (Warn_On_Known_Condition): Suppress warning for comparison of attribute result with constant * a-ststio.adb, s-direio.adb, s-rannum.adb: Remove unnecessary pragma Warnings (Off, ".."); 2013-01-02 Yannick Moy <moy@adacore.com> * sem_prag.ads: Minor correction of comment. 2013-01-02 Thomas Quinot <quinot@adacore.com> * par_sco.adb (Traverse_Package_Declaration): The first declaration in a nested package is dominated by the preceding declaration in the enclosing scope. 2013-01-02 Pascal Obry <obry@adacore.com> * adaint.c, adaint.h (__gnat_get_module_name): Return the actual module containing a given address. From-SVN: r194798
Diffstat (limited to 'gcc/ada/adaint.c')
-rw-r--r--gcc/ada/adaint.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 4b8ce53..e67c4df 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -2960,6 +2960,45 @@ __gnat_locate_exec_on_path (char *exec_name)
#endif
}
+/* __gnat_get_module_name returns the module name (executable or shared
+ library) in which the code at addr is. This is used to properly
+ report the symbolic tracebacks. If the module cannot be located
+ it returns the empty string. The returned value must not be freed. */
+
+char *__gnat_get_module_name (void *addr ATTRIBUTE_UNUSED)
+{
+ extern char **gnat_argv;
+
+#ifdef _WIN32
+ static char lpFilename[MAX_PATH];
+ HMODULE hModule;
+
+ lpFilename[0] = '\0';
+
+ /* Get the module handle in which the code running at the specified
+ address is contained. */
+
+ if (GetModuleHandleEx
+ (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, addr, &hModule) == FALSE)
+ return __gnat_locate_exec_on_path (gnat_argv[0]);
+
+ /* Get the corresponding module full path name. We really want the
+ standard ASCII version of this routine as the name is passed to
+ the BFD library. */
+
+ if (GetModuleFileNameA (hModule, lpFilename, MAX_PATH) == 0)
+ return __gnat_locate_exec_on_path (gnat_argv[0]);
+
+ return lpFilename;
+
+#else
+ /* On all other platforms we just return the full path name of the
+ main executable. */
+
+ return __gnat_locate_exec_on_path (gnat_argv[0]);
+#endif
+}
+
#ifdef VMS
/* These functions are used to translate to and from VMS and Unix syntax