Commit 747412b8 by Arnaud Charlet

[multiple changes]

2013-10-14  Vincent Celier  <celier@adacore.com>

	* projects.texi: Add documentation for new attributes of package
	Clean: Artifacts_In_Object_Dir and Artifacts_In_Exec_Dir.

2013-10-14  Tristan Gingold  <gingold@adacore.com>

	* adaint.c, adaint.h (__gnat_get_executable_load_address):
	New function.
	* a-exexda.adb (Append_Info_Basic_Exception_Traceback): Add
	executable load address (Basic_Exception_Tback_Maxlength): Adjust.

From-SVN: r203530
parent 3599a97b
2013-10-14 Vincent Celier <celier@adacore.com> 2013-10-14 Vincent Celier <celier@adacore.com>
* projects.texi: Add documentation for new attributes of package
Clean: Artifacts_In_Object_Dir and Artifacts_In_Exec_Dir.
2013-10-14 Tristan Gingold <gingold@adacore.com>
* adaint.c, adaint.h (__gnat_get_executable_load_address):
New function.
* a-exexda.adb (Append_Info_Basic_Exception_Traceback): Add
executable load address (Basic_Exception_Tback_Maxlength): Adjust.
2013-10-14 Vincent Celier <celier@adacore.com>
* prj-attr.adb: New attributes in package Clean: * prj-attr.adb: New attributes in package Clean:
Artifacts_In_Exec_Dir, Artifacts_In_Object_Dir. Artifacts_In_Exec_Dir, Artifacts_In_Object_Dir.
* prj-nmsc.adb (Process_Clean (Attributes)): New * prj-nmsc.adb (Process_Clean (Attributes)): New
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -206,6 +206,11 @@ package body Exception_Data is ...@@ -206,6 +206,11 @@ package body Exception_Data is
pragma Export pragma Export
(Ada, Exception_Message_Length, "__gnat_exception_msg_len"); (Ada, Exception_Message_Length, "__gnat_exception_msg_len");
function Get_Executable_Load_Address return System.Address;
pragma Import (C, Get_Executable_Load_Address,
"__gnat_get_executable_load_address");
-- Get the load address of the executable, or Null_Address if not known
------------------------- -------------------------
-- Append_Info_Address -- -- Append_Info_Address --
------------------------- -------------------------
...@@ -377,17 +382,29 @@ package body Exception_Data is ...@@ -377,17 +382,29 @@ package body Exception_Data is
-- As for Basic_Exception_Information: -- As for Basic_Exception_Information:
BETB_Header : constant String := "Call stack traceback locations:"; BETB_Header : constant String := "Call stack traceback locations:";
LDAD_Header : constant String := "Load address: ";
procedure Append_Info_Basic_Exception_Traceback procedure Append_Info_Basic_Exception_Traceback
(X : Exception_Occurrence; (X : Exception_Occurrence;
Info : in out String; Info : in out String;
Ptr : in out Natural) Ptr : in out Natural)
is is
Load_Address : Address;
begin begin
if X.Num_Tracebacks = 0 then if X.Num_Tracebacks = 0 then
return; return;
end if; end if;
-- The executable load address line
Load_Address := Get_Executable_Load_Address;
if Load_Address /= Null_Address then
Append_Info_String (LDAD_Header, Info, Ptr);
Append_Info_Address (Load_Address, Info, Ptr);
Append_Info_NL (Info, Ptr);
end if;
-- The traceback lines
Append_Info_String (BETB_Header, Info, Ptr); Append_Info_String (BETB_Header, Info, Ptr);
Append_Info_NL (Info, Ptr); Append_Info_NL (Info, Ptr);
...@@ -407,11 +424,12 @@ package body Exception_Data is ...@@ -407,11 +424,12 @@ package body Exception_Data is
function Basic_Exception_Tback_Maxlength function Basic_Exception_Tback_Maxlength
(X : Exception_Occurrence) return Natural (X : Exception_Occurrence) return Natural
is is
Space_Per_Traceback : constant := 2 + 16 + 1; Space_Per_Address : constant := 2 + 16 + 1;
-- Space for "0x" + HHHHHHHHHHHHHHHH + " " -- Space for "0x" + HHHHHHHHHHHHHHHH + " "
begin begin
return BETB_Header'Length + 1 + return LDAD_Header'Length + Space_Per_Address +
X.Num_Tracebacks * Space_Per_Traceback + 1; BETB_Header'Length + 1 +
X.Num_Tracebacks * Space_Per_Address + 1;
end Basic_Exception_Tback_Maxlength; end Basic_Exception_Tback_Maxlength;
--------------------------------------- ---------------------------------------
......
...@@ -3830,8 +3830,8 @@ void GetTimeAsFileTime(LPFILETIME pTime) ...@@ -3830,8 +3830,8 @@ void GetTimeAsFileTime(LPFILETIME pTime)
extern void __main (void); extern void __main (void);
void __main (void) {} void __main (void) {}
#endif #endif /* RTSS */
#endif #endif /* RTX */
#if defined (__ANDROID__) #if defined (__ANDROID__)
...@@ -3889,7 +3889,7 @@ void __gnat_cpu_set (int cpu, size_t count, cpu_set_t *set) ...@@ -3889,7 +3889,7 @@ void __gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
CPU_SET_S (cpu - 1, count, set); CPU_SET_S (cpu - 1, count, set);
} }
#else #else /* !CPU_ALLOC */
/* Static cpu sets */ /* Static cpu sets */
...@@ -3919,8 +3919,59 @@ void __gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) ...@@ -3919,8 +3919,59 @@ void __gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
CPU by a 0, so we need to adjust. */ CPU by a 0, so we need to adjust. */
CPU_SET (cpu - 1, set); CPU_SET (cpu - 1, set);
} }
#endif /* !CPU_ALLOC */
#endif /* linux */
/* Return the load address of the executable, or 0 if not known. In the
specific case of error, (void *)-1 can be returned. Beware: this unit may
be in a shared library. As low-level units are needed, we allow #include
here. */
#if defined (__APPLE__)
#include <mach-o/dyld.h>
#elif defined (__linux__)
#include <link.h>
#elif defined (__AIX__)
#include <sys/ldr.h>
#endif #endif
const void *
__gnat_get_executable_load_address (void)
{
#if defined (__APPLE__)
return _dyld_get_image_header (0);
#elif defined (__linux__)
struct link_map *map = _r_debug.r_map;
return (const void *)map->l_addr;
#elif defined (__AIX__)
/* Unfortunately, AIX wants to return the info for all loaded objects,
so we need to increase the buffer if too small. */
size_t blen = 4096;
int status;
while (1)
{
char buf[blen];
status = loadquery (L_GETINFO, buf, blen);
if (status == 0)
{
struct ldinfo *info = (struct ld_info *)buf;
return info->ldinfo_textorg;
}
blen = blen * 2;
/* Avoid stack overflow. */
if (blen > 40 * 1024)
return (const void *)-1;
}
#else
return NULL;
#endif #endif
}
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -287,6 +287,8 @@ extern int get_gcc_version (void); ...@@ -287,6 +287,8 @@ extern int get_gcc_version (void);
extern int __gnat_binder_supports_auto_init (void); extern int __gnat_binder_supports_auto_init (void);
extern int __gnat_sals_init_using_constructors (void); extern int __gnat_sals_init_using_constructors (void);
extern const void * __gnat_get_executable_load_address (void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
...@@ -4292,6 +4292,16 @@ Index is a language names. Value is the list of extensions for file names ...@@ -4292,6 +4292,16 @@ Index is a language names. Value is the list of extensions for file names
derived from source file names that need to be cleaned in the object derived from source file names that need to be cleaned in the object
directory of the project. directory of the project.
@item @b{Artifacts_In_Object_Dir}: single
Value is a list of file names expressed as regular expressions that are to be
deleted by gprclean in the object directory of the project.
@item @b{Artifacts_In_Exec_Dir}: single
Value is list of file names expressed as regular expressions that are to be
deleted by gprclean in the exec directory of the main project.
@end itemize @end itemize
@node Package Compiler Attributes @node Package Compiler Attributes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment