Commit b8bbe739 by Olivier Hainque Committed by Pierre-Marie de Rodat

[Ada] Prevent caching of non-text symbols for symbolic tracebacks

We now only have the executable code section boundaries at hand,
so can only infer offsets for symbols within those boundaries.

Symbols outside of this region are non-text symbols, pointless for
traceback symbolization anyway.

2018-05-22  Olivier Hainque  <hainque@adacore.com>

gcc/ada/

	* libgnat/s-dwalin.adb (Enable_Cache): Skip symbols outside of the
	executable code section boundaries.

From-SVN: r260510
parent 92ea8dd2
2018-05-22 Olivier Hainque <hainque@adacore.com>
* libgnat/s-dwalin.adb (Enable_Cache): Skip symbols outside of the
executable code section boundaries.
2018-05-22 Javier Miranda <miranda@adacore.com> 2018-05-22 Javier Miranda <miranda@adacore.com>
* locales.c: New implementation for the Ada.Locales package. * locales.c: New implementation for the Ada.Locales package.
......
...@@ -1202,6 +1202,9 @@ package body System.Dwarf_Lines is ...@@ -1202,6 +1202,9 @@ package body System.Dwarf_Lines is
-- Phase 1: count number of symbols. Phase 2: fill the cache. -- Phase 1: count number of symbols. Phase 2: fill the cache.
declare declare
S : Object_Symbol; S : Object_Symbol;
Val : uint64;
Xcode_Low : constant uint64 := uint64 (C.Low);
Xcode_High : constant uint64 := uint64 (C.High);
Sz : uint32; Sz : uint32;
Addr, Prev_Addr : uint32; Addr, Prev_Addr : uint32;
Nbr_Symbols : Natural; Nbr_Symbols : Natural;
...@@ -1211,22 +1214,31 @@ package body System.Dwarf_Lines is ...@@ -1211,22 +1214,31 @@ package body System.Dwarf_Lines is
S := First_Symbol (C.Obj.all); S := First_Symbol (C.Obj.all);
Prev_Addr := uint32'Last; Prev_Addr := uint32'Last;
while S /= Null_Symbol loop while S /= Null_Symbol loop
-- Discard symbols whose length is 0 -- Discard symbols of length 0 or located outside of the
-- execution code section outer boundaries.
Sz := uint32 (Size (S)); Sz := uint32 (Size (S));
Val := Value (S);
-- Try to filter symbols at the same address. This is a best if Sz > 0
-- effort as they might not be consecutive. and then Val >= Xcode_Low
Addr := uint32 (Value (S) - uint64 (C.Low)); and then Val <= Xcode_High
if Sz > 0 and then Addr /= Prev_Addr then then
Nbr_Symbols := Nbr_Symbols + 1;
Prev_Addr := Addr; Addr := uint32 (Val - Xcode_Low);
if Phase = 2 then -- Try to filter symbols at the same address. This is a best
C.Cache (Nbr_Symbols) := -- effort as they might not be consecutive.
(First => Addr, if Addr /= Prev_Addr then
Size => Sz, Nbr_Symbols := Nbr_Symbols + 1;
Sym => uint32 (Off (S)), Prev_Addr := Addr;
Line => 0);
if Phase = 2 then
C.Cache (Nbr_Symbols) :=
(First => Addr,
Size => Sz,
Sym => uint32 (Off (S)),
Line => 0);
end if;
end if; end if;
end if; end if;
......
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