File: fpdbgsymtable.pas

package info (click to toggle)
lazarus 2.2.6%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 219,980 kB
  • sloc: pascal: 1,944,919; xml: 357,634; makefile: 270,608; cpp: 57,115; sh: 3,249; java: 609; perl: 297; sql: 222; ansic: 137
file content (78 lines) | stat: -rw-r--r-- 1,940 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
unit fpDbgSymTable;

{$mode objfpc}{$H+}

interface

uses
  DbgIntfBaseTypes,
  fgl, Classes;

type

  TfpLinkerSymbol = record
    Addr: TDBGPtr;
    SectionEnd: TDBGPtr; // Max upper Addr bound
  end;
  PfpLinkerSymbol = ^TfpLinkerSymbol;

  { TfpSymbolList }

  // TODO: TFPGMapObject, if we store more data
  TfpSymbolList= class(specialize TFPGMap<String, TfpLinkerSymbol>)
  private
    FHighAddr: TDBGPtr;
    FLowAddr: TDBGPtr;
    function GetDataPtr(const AIndex: Integer): PfpLinkerSymbol;
    function GetKeyDataPtr(const AKey: string): PfpLinkerSymbol;
  public
    procedure SetAddressBounds(ALowAddr, AHighAddr: TDBGPtr);
    property LowAddr: TDBGPtr read FLowAddr;
    property HighAddr: TDBGPtr read FHighAddr;
    function Add(const AKey: String; const AData: TDBGPtr): Integer; inline; overload;
    function Add(const AKey: String; const AData, ASectionEnd: TDBGPtr): Integer; inline; overload;
    property KeyDataPtr[const AKey: string]: PfpLinkerSymbol read GetKeyDataPtr;
    property DataPtr[const AIndex: Integer]: PfpLinkerSymbol read GetDataPtr;
  end;

implementation

{ TfpSymbolList }

function TfpSymbolList.GetDataPtr(const AIndex: Integer): PfpLinkerSymbol;
begin
  Result := PfpLinkerSymbol(TFPSMap(Self).Data[AIndex]);
end;

function TfpSymbolList.GetKeyDataPtr(const AKey: string): PfpLinkerSymbol;
begin
  Result := PfpLinkerSymbol(TFPSMap(Self).KeyData[@AKey]);
end;

procedure TfpSymbolList.SetAddressBounds(ALowAddr, AHighAddr: TDBGPtr);
begin
  FLowAddr := ALowAddr;
  FHighAddr := AHighAddr;
end;

function TfpSymbolList.Add(const AKey: String; const AData: TDBGPtr): Integer;
var
  d: TfpLinkerSymbol;
begin
  d.Addr := AData;
  d.SectionEnd := 0;
  Result := Add(AKey, d);
end;

function TfpSymbolList.Add(const AKey: String; const AData, ASectionEnd: TDBGPtr
  ): Integer;
var
  d: TfpLinkerSymbol;
begin
  d.Addr := AData;
  d.SectionEnd := ASectionEnd;
  Result := Add(AKey, d);
end;

end.