View Issue Details

IDProjectCategoryView StatusLast Update
0033914FPCCompilerpublic2019-07-26 20:58
ReporterChristo CrauseAssigned ToJeppe Johansen 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.1.1Product Build38524 
Target VersionFixed in Version3.3.1 
Summary0033914: AVR - invalid address used when evaluating a variable in gdb
DescriptionWhen debugging an AVR program in Lazarus I noticed incorrect variable values being displayed. This appears to be caused by gdb requesting the memory content of the wrong address space (flash instead of SRAM).

I've mentioned this on the gdb forum, where the conclusion was that it is probably related to incorrect symbol/debug information, see this reply: https://sourceware.org/ml/gdb/2018-06/msg00013.html

See additional information below for example gdb session.
Steps To ReproduceCompile following using:
fpc/3.1.1/compiler/ppcrossavr -Tembedded -Pavr -CpAVR25 -MObjFPC -Scghi -O4 -g -l -vewnhibq
-Filib/avr-embedded -Fu../../library -Fu. -FUlib/avr-embedded -FE. -oblink -Wpattiny45 -g -a
-XPavr- -al -Sm -Si -dF_CPU:=8000000 blink.pp

Code:

program blink;

uses
  intrinsics;

const
  LEDpin = 1 shl 4;
  CS00msk = 1 shl 0;
  CS01msk = 1 shl 1;
  CS02msk = 1 shl 2;

  TOIE0msk =
  {$ifdef FPC_MCU_ATTINY45}
   1 shl 1;
  {$else} // defaults to atmega328p
   1 shl 0;
  {$endif}

var
  countsPerSecond: byte;
  LEDport: byte absolute PORTB;
  LEDdir: byte absolute DDRB;
  i: byte = 1;

procedure Timer0Overflow; alias: 'TIMER0_OVF_ISR'; interrupt;
begin
  inc(i);
  if i > countsPerSecond then
  begin
    LEDport := LEDport xor LEDpin;
    i := 0;
  end;
end;

begin
  countsPerSecond := (((F_CPU div 1024) + 128) div 256 div 3); // 3 Hz
  LEDdir := LEDdir or LEDpin; // Set pin to output
  LEDport := LEDport or LEDpin; // Set LED high

  TCCR0A := 0;
  TCCR0B := CS02msk or CS00msk; // clock prescaler = 1024
  // enable timer1 overflow interrupt
  {$ifdef FPC_MCU_ATTINY45}
  TIMSK
  {$else} // defaults to atmega328p
  TIMSK0
  {$endif}
  := TOIE0msk;

  avr_sei;
  while True do;
end.
Additional InformationAn example of a gdb session:
~/fpc/fpc-avr/src/examples/blink2 $ ~/gdb/gdb-8.1/gdb/avr-gdb-8.1.0-original
GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=avr".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) file bin/blink.elf
Reading symbols from bin/blink.elf...done.
(gdb) target remote :2345
Remote debugging using :2345
0x00000000 in _START ()
(gdb) load
Loading section .text, size 0xb2 lma 0x0
Loading section .data, size 0x2 lma 0xb2
Start address 0x0, load size 180
Transfer rate: 505 bytes/sec, 25 bytes/write.
(gdb) set language pascal
(gdb) set debug remote 1
(gdb) print i
Sending packet: $m60,1#30...Ack
Packet received: 20
$1 = 32
(gdb) print @i
$2 = (^Sending packet: $m800060,8#ff...Ack
Packet received: 04000A00F6777DD2
Byte) 0x800060 0000004
(gdb) print (@i)^
Sending packet: $m800060,1#f8...Ack
Packet received: 04
$3 = 4
(gdb)
TagsAVR
Fixed in Revision42493
FPCOldBugId
FPCTarget-
Attached Files
  • dbgdwarf-try-1.patch (13,326 bytes)
    Index: compiler/dbgdwarf.pas
    ===================================================================
    --- compiler/dbgdwarf.pas	(revision 39317)
    +++ compiler/dbgdwarf.pas	(working copy)
    @@ -48,6 +48,14 @@
           DbgBase;
     
         type
    +      {$ifdef avr}
    +      puint_d = cardinal;
    +      pint_d = longint;
    +      {$else avr}
    +      puint_d = PUint;
    +      pint_d = pint;
    +      {$endif avr}
    +
           { Tag names and codes.   }
           tdwarf_tag = (DW_TAG_padding := $00,DW_TAG_array_type := $01,
             DW_TAG_class_type := $02,DW_TAG_entry_point := $03,
    @@ -396,11 +404,11 @@
             procedure appenddef_procvar(list:TAsmList;def:tprocvardef);override;
             procedure appendprocdef(list:TAsmList;def:tprocdef);override;
     
    -        function  get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint): boolean;
    +        function  get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint_d): boolean;
             procedure appendsym_var(list:TAsmList;sym:tabstractnormalvarsym);
    -        procedure appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint; const flags: tdwarfvarsymflags);
    +        procedure appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint_d; const flags: tdwarfvarsymflags);
             { used for fields and properties mapped to fields }
    -        procedure appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint);
    +        procedure appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint_d);
             procedure appendsym_const_member(list:TAsmList;sym:tconstsym;ismember:boolean);
     
             procedure beforeappendsym(list:TAsmList;sym:tsym);override;
    @@ -538,6 +546,12 @@
           { Implementation-defined range start.   }
           DW_LANG_hi_user = $ffff;
     
    +      {$ifdef avr}
    +      aitconst_ptr_unaligned_d = aitconst_32bit_unaligned;
    +      {$else avr}
    +      aitconst_ptr_unaligned_d = aitconst_ptr_unaligned;
    +      {$endif avr}
    +
         type
           { Names and codes for macro information.   }
           tdwarf_macinfo_record_type = (DW_MACINFO_define := 1,DW_MACINFO_undef := 2,
    @@ -1315,7 +1329,7 @@
           begin
             AddConstToAbbrev(ord(attr));
             AddConstToAbbrev(ord(DW_FORM_addr));
    -        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned,sym));
    +        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,sym));
           end;
     
         procedure TDebugInfoDwarf.append_labelentry_addr_ref(attr : tdwarf_attribute;sym : tasmsymbol);
    @@ -1325,7 +1339,7 @@
             { DW_FORM_ref_addr is treated as 32-bit by Open Watcom on i8086 }
             current_asmdata.asmlists[al_dwarf_info].concat(tai_const.Create_type_sym(aitconst_32bit_unaligned,sym));
     {$else i8086}
    -        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned,sym));
    +        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,sym));
     {$endif i8086}
           end;
     
    @@ -1822,8 +1836,8 @@
     
         procedure TDebugInfoDwarf.appenddef_array(list:TAsmList;def:tarraydef);
           var
    -        size : PInt;
    -        elesize : PInt;
    +        size : PInt_d;
    +        elesize : PInt_d;
             elestrideattr : tdwarf_attribute;
             labsym: tasmlabel;
           begin
    @@ -2089,7 +2103,7 @@
                 else
                   current_asmdata.getaddrlabel(proc);
                 append_entry(DW_TAG_structure_type,true,[
    -              DW_AT_byte_size,DW_FORM_data1,2*sizeof(pint)
    +              DW_AT_byte_size,DW_FORM_data1,2*sizeof(pint_d)
                 ]);
                 finish_entry;
     
    @@ -2106,10 +2120,10 @@
                 { self entry }
                 append_entry(DW_TAG_member,false,[
                   DW_AT_name,DW_FORM_string,'Self'#0,
    -              DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(sizeof(pint))
    +              DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(sizeof(pint_d))
                   ]);
                 current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
    -            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(sizeof(pint)));
    +            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(sizeof(pint_d)));
                 append_labelentry_ref(DW_AT_type,def_dwarf_lab(class_tobject));
                 finish_entry;
     
    @@ -2255,7 +2269,7 @@
             procentry      : string;
             cc             : Tdwarf_calling_convention;
             st             : tsymtable;
    -        vmtoffset      : pint;
    +        vmtoffset      : pint_d;
             in_currentunit : boolean;
           begin
             { only write debug info for procedures defined in the current module,
    @@ -2385,7 +2399,7 @@
                     current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_seg_name(procentry));
     {$endif i8086}
                     current_asmdata.asmlists[al_dwarf_aranges].Concat(
    -                  tai_const.Create_rel_sym(aitconst_ptr_unaligned,current_asmdata.RefAsmSymbol(procentry,AT_FUNCTION),procendlabel));
    +                  tai_const.Create_rel_sym(aitconst_ptr_unaligned_d,current_asmdata.RefAsmSymbol(procentry,AT_FUNCTION),procendlabel));
     {$ifdef i8086}
                     { bits 16..31 of length }
                     current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_16bit_unaligned(0));
    @@ -2436,9 +2450,9 @@
           end;
     
     
    -    function TDebugInfoDwarf.get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint): boolean;
    +    function TDebugInfoDwarf.get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint_d): boolean;
           var
    -        elesize : pint;
    +        elesize : pint_d;
             currdef : tdef;
             indirection: boolean;
           begin
    @@ -2528,7 +2542,7 @@
           end;
     
     
    -    procedure TDebugInfoDwarf.appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint; const flags: tdwarfvarsymflags);
    +    procedure TDebugInfoDwarf.appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint_d; const flags: tdwarfvarsymflags);
           var
             templist : TAsmList;
             blocksize,size_of_int : longint;
    @@ -2618,15 +2632,15 @@
     { This is only a minimal change to at least be able to get a value
       in only one thread is present PM 2014-11-21, like for stabs format }
                             templist.concat(tai_const.create_8bit(ord(DW_OP_addr)));
    -                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned,sym.mangledname,
    -                          offset+sizeof(pint)));
    -                        blocksize:=1+sizeof(puint);
    +                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,
    +                          offset+sizeof(pint_d)));
    +                        blocksize:=1+sizeof(puint_d);
                           end
                         else
                           begin
                             templist.concat(tai_const.create_8bit(ord(DW_OP_addr)));
    -                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned,sym.mangledname,offset));
    -                        blocksize:=1+sizeof(puint);
    +                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,offset));
    +                        blocksize:=1+sizeof(puint_d);
     {$ifdef i8086}
                             segment_sym_name:=sym.mangledname;
                             has_segment_sym_name:=true;
    @@ -2806,7 +2820,7 @@
           end;
     
     
    -    procedure TDebugInfoDwarf.appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint);
    +    procedure TDebugInfoDwarf.appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint_d);
           var
             bitoffset,
             fieldoffset,
    @@ -2842,7 +2856,7 @@
                 { possible, i.e., equivalent to gcc's                    }
                 { __attribute__((__packed__)), which is also what gpc    }
                 { does.                                                  }
    -            fieldnatsize:=max(sizeof(pint),sym.vardef.size);
    +            fieldnatsize:=max(sizeof(pint_d),sym.vardef.size);
                 fieldoffset:=(sym.fieldoffset div (fieldnatsize*8)) * fieldnatsize;
                 inc(fieldoffset,offset);
                 bitoffset:=sym.fieldoffset mod (fieldnatsize*8);
    @@ -3053,7 +3067,7 @@
           var
             symlist: ppropaccesslistitem;
             tosym: tabstractvarsym;
    -        offset: pint;
    +        offset: pint_d;
           begin
             if assigned(sym.propaccesslist[palt_read]) and
                not assigned(sym.propaccesslist[palt_read].procdef) then
    @@ -3096,7 +3110,7 @@
             blocksize : longint;
             symlist : ppropaccesslistitem;
             tosym: tabstractvarsym;
    -        offset: pint;
    +        offset: pint_d;
             flags: tdwarfvarsymflags;
           begin
             templist:=TAsmList.create;
    @@ -3113,13 +3127,13 @@
                    *)
                    templist.concat(tai_const.create_8bit(3));
                    templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset));
    -               blocksize:=1+sizeof(puint);
    +               blocksize:=1+sizeof(puint_d);
                 end;
               toasm :
                 begin
                   templist.concat(tai_const.create_8bit(3));
    -              templist.concat(tai_const.create_type_name(aitconst_ptr_unaligned,sym.mangledname,0));
    -              blocksize:=1+sizeof(puint);
    +              templist.concat(tai_const.create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,0));
    +              blocksize:=1+sizeof(puint_d);
                 end;
               tovar:
                 begin
    @@ -3422,7 +3436,7 @@
                 { no alignment/padding bytes on i8086 for Open Watcom compatibility }
     {$else i8086}
                 { address_size }
    -            current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint)));
    +            current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint_d)));
                 { segment_size }
                 current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(0));
                 { alignment }
    @@ -3454,7 +3468,7 @@
                 current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_abbrev0',AB_LOCAL,AT_METADATA,voidpointertype)));
     
             { address size }
    -        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(pint)));
    +        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(pint_d)));
     
             if (ds_dwarf_cpp in current_settings.debugswitches) then
               lang:=DW_LANG_C_plus_plus
    @@ -3781,9 +3795,9 @@
                            (target_asm.id=as_solaris_as) then
                           begin
                             asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
    -                        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
    +                        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
                             asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
    -                        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,currlabel));
    +                        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,currlabel));
     {$ifdef i8086}
                             { on i8086 we also emit an Open Watcom-specific 'set segment' op }
                             asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
    @@ -3853,9 +3867,9 @@
                 current_asmdata.getlabel(currlabel, alt_dbgline);
                 list.insertafter(tai_label.create(currlabel), hpend);
                 asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
    -            asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
    +            asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
                 asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
    -            asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,currlabel));
    +            asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,currlabel));
               end;
     
             { end sequence }
    @@ -3887,9 +3901,9 @@
             asmline.concat(tai_const.create_uleb128bit(get_file_index(infile)));
     
             asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
    -        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
    +        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
             asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
    -        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,nil));
    +        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,nil));
             asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
             asmline.concat(tai_const.Create_8bit(1));
             asmline.concat(tai_const.Create_8bit(DW_LNE_end_sequence));
    
    dbgdwarf-try-1.patch (13,326 bytes)
  • dbgdwarf-try-2.patch (14,839 bytes)
    Index: compiler/dbgdwarf.pas
    ===================================================================
    --- compiler/dbgdwarf.pas	(revision 39317)
    +++ compiler/dbgdwarf.pas	(working copy)
    @@ -48,6 +48,16 @@
           DbgBase;
     
         type
    +      {$ifdef avr}
    +      puint_d = cardinal;
    +      pint_d = longint;
    +      //puint_d = PUint;
    +      //pint_d = pint;
    +      {$else avr}
    +      puint_d = PUint;
    +      pint_d = pint;
    +      {$endif avr}
    +
           { Tag names and codes.   }
           tdwarf_tag = (DW_TAG_padding := $00,DW_TAG_array_type := $01,
             DW_TAG_class_type := $02,DW_TAG_entry_point := $03,
    @@ -396,11 +406,11 @@
             procedure appenddef_procvar(list:TAsmList;def:tprocvardef);override;
             procedure appendprocdef(list:TAsmList;def:tprocdef);override;
     
    -        function  get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint): boolean;
    +        function  get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint_d): boolean;
             procedure appendsym_var(list:TAsmList;sym:tabstractnormalvarsym);
    -        procedure appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint; const flags: tdwarfvarsymflags);
    +        procedure appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint_d; const flags: tdwarfvarsymflags);
             { used for fields and properties mapped to fields }
    -        procedure appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint);
    +        procedure appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint_d);
             procedure appendsym_const_member(list:TAsmList;sym:tconstsym;ismember:boolean);
     
             procedure beforeappendsym(list:TAsmList;sym:tsym);override;
    @@ -538,6 +548,13 @@
           { Implementation-defined range start.   }
           DW_LANG_hi_user = $ffff;
     
    +      {$ifdef avr}
    +      aitconst_ptr_unaligned_d = aitconst_32bit_unaligned;
    +      //aitconst_ptr_unaligned_d = aitconst_ptr_unaligned;
    +      {$else avr}
    +      aitconst_ptr_unaligned_d = aitconst_ptr_unaligned;
    +      {$endif avr}
    +
         type
           { Names and codes for macro information.   }
           tdwarf_macinfo_record_type = (DW_MACINFO_define := 1,DW_MACINFO_undef := 2,
    @@ -1315,7 +1332,7 @@
           begin
             AddConstToAbbrev(ord(attr));
             AddConstToAbbrev(ord(DW_FORM_addr));
    -        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned,sym));
    +        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,sym));
           end;
     
         procedure TDebugInfoDwarf.append_labelentry_addr_ref(attr : tdwarf_attribute;sym : tasmsymbol);
    @@ -1325,7 +1342,7 @@
             { DW_FORM_ref_addr is treated as 32-bit by Open Watcom on i8086 }
             current_asmdata.asmlists[al_dwarf_info].concat(tai_const.Create_type_sym(aitconst_32bit_unaligned,sym));
     {$else i8086}
    -        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned,sym));
    +        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,sym));
     {$endif i8086}
           end;
     
    @@ -1822,8 +1839,8 @@
     
         procedure TDebugInfoDwarf.appenddef_array(list:TAsmList;def:tarraydef);
           var
    -        size : PInt;
    -        elesize : PInt;
    +        size : PInt_d;
    +        elesize : PInt_d;
             elestrideattr : tdwarf_attribute;
             labsym: tasmlabel;
           begin
    @@ -2089,7 +2106,7 @@
                 else
                   current_asmdata.getaddrlabel(proc);
                 append_entry(DW_TAG_structure_type,true,[
    -              DW_AT_byte_size,DW_FORM_data1,2*sizeof(pint)
    +              DW_AT_byte_size,DW_FORM_data1,2*sizeof(pint_d)
                 ]);
                 finish_entry;
     
    @@ -2106,10 +2123,10 @@
                 { self entry }
                 append_entry(DW_TAG_member,false,[
                   DW_AT_name,DW_FORM_string,'Self'#0,
    -              DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(sizeof(pint))
    +              DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(sizeof(pint_d))
                   ]);
                 current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
    -            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(sizeof(pint)));
    +            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(sizeof(pint_d)));
                 append_labelentry_ref(DW_AT_type,def_dwarf_lab(class_tobject));
                 finish_entry;
     
    @@ -2255,7 +2272,7 @@
             procentry      : string;
             cc             : Tdwarf_calling_convention;
             st             : tsymtable;
    -        vmtoffset      : pint;
    +        vmtoffset      : pint_d;
             in_currentunit : boolean;
           begin
             { only write debug info for procedures defined in the current module,
    @@ -2385,7 +2402,7 @@
                     current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_seg_name(procentry));
     {$endif i8086}
                     current_asmdata.asmlists[al_dwarf_aranges].Concat(
    -                  tai_const.Create_rel_sym(aitconst_ptr_unaligned,current_asmdata.RefAsmSymbol(procentry,AT_FUNCTION),procendlabel));
    +                  tai_const.Create_rel_sym(aitconst_ptr_unaligned_d,current_asmdata.RefAsmSymbol(procentry,AT_FUNCTION),procendlabel));
     {$ifdef i8086}
                     { bits 16..31 of length }
                     current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_16bit_unaligned(0));
    @@ -2436,9 +2453,9 @@
           end;
     
     
    -    function TDebugInfoDwarf.get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint): boolean;
    +    function TDebugInfoDwarf.get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint_d): boolean;
           var
    -        elesize : pint;
    +        elesize : pint_d;
             currdef : tdef;
             indirection: boolean;
           begin
    @@ -2528,7 +2545,7 @@
           end;
     
     
    -    procedure TDebugInfoDwarf.appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint; const flags: tdwarfvarsymflags);
    +    procedure TDebugInfoDwarf.appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint_d; const flags: tdwarfvarsymflags);
           var
             templist : TAsmList;
             blocksize,size_of_int : longint;
    @@ -2618,15 +2635,15 @@
     { This is only a minimal change to at least be able to get a value
       in only one thread is present PM 2014-11-21, like for stabs format }
                             templist.concat(tai_const.create_8bit(ord(DW_OP_addr)));
    -                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned,sym.mangledname,
    -                          offset+sizeof(pint)));
    -                        blocksize:=1+sizeof(puint);
    +                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,
    +                          offset+sizeof(pint_d)));
    +                        blocksize:=1+sizeof(puint_d);
                           end
                         else
                           begin
                             templist.concat(tai_const.create_8bit(ord(DW_OP_addr)));
    -                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned,sym.mangledname,offset));
    -                        blocksize:=1+sizeof(puint);
    +                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,offset));
    +                        blocksize:=1+sizeof(puint_d);
     {$ifdef i8086}
                             segment_sym_name:=sym.mangledname;
                             has_segment_sym_name:=true;
    @@ -2806,7 +2823,7 @@
           end;
     
     
    -    procedure TDebugInfoDwarf.appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint);
    +    procedure TDebugInfoDwarf.appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint_d);
           var
             bitoffset,
             fieldoffset,
    @@ -2842,7 +2859,7 @@
                 { possible, i.e., equivalent to gcc's                    }
                 { __attribute__((__packed__)), which is also what gpc    }
                 { does.                                                  }
    -            fieldnatsize:=max(sizeof(pint),sym.vardef.size);
    +            fieldnatsize:=max(sizeof(pint_d),sym.vardef.size);
                 fieldoffset:=(sym.fieldoffset div (fieldnatsize*8)) * fieldnatsize;
                 inc(fieldoffset,offset);
                 bitoffset:=sym.fieldoffset mod (fieldnatsize*8);
    @@ -3053,7 +3070,7 @@
           var
             symlist: ppropaccesslistitem;
             tosym: tabstractvarsym;
    -        offset: pint;
    +        offset: pint_d;
           begin
             if assigned(sym.propaccesslist[palt_read]) and
                not assigned(sym.propaccesslist[palt_read].procdef) then
    @@ -3096,7 +3113,7 @@
             blocksize : longint;
             symlist : ppropaccesslistitem;
             tosym: tabstractvarsym;
    -        offset: pint;
    +        offset: pint_d;
             flags: tdwarfvarsymflags;
           begin
             templist:=TAsmList.create;
    @@ -3112,14 +3129,15 @@
                      end;
                    *)
                    templist.concat(tai_const.create_8bit(3));
    -               templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset));
    -               blocksize:=1+sizeof(puint);
    +               //templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset));
    +               templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset, aitconst_ptr_unaligned_d));
    +               blocksize:=1+sizeof(puint_d);
                 end;
               toasm :
                 begin
                   templist.concat(tai_const.create_8bit(3));
    -              templist.concat(tai_const.create_type_name(aitconst_ptr_unaligned,sym.mangledname,0));
    -              blocksize:=1+sizeof(puint);
    +              templist.concat(tai_const.create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,0));
    +              blocksize:=1+sizeof(puint_d);
                 end;
               tovar:
                 begin
    @@ -3422,7 +3440,7 @@
                 { no alignment/padding bytes on i8086 for Open Watcom compatibility }
     {$else i8086}
                 { address_size }
    -            current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint)));
    +            current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint_d)));
                 { segment_size }
                 current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(0));
                 { alignment }
    @@ -3454,7 +3472,7 @@
                 current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_abbrev0',AB_LOCAL,AT_METADATA,voidpointertype)));
     
             { address size }
    -        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(pint)));
    +        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(pint_d)));
     
             if (ds_dwarf_cpp in current_settings.debugswitches) then
               lang:=DW_LANG_C_plus_plus
    @@ -3781,9 +3799,9 @@
                            (target_asm.id=as_solaris_as) then
                           begin
                             asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
    -                        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
    +                        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
                             asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
    -                        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,currlabel));
    +                        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,currlabel));
     {$ifdef i8086}
                             { on i8086 we also emit an Open Watcom-specific 'set segment' op }
                             asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
    @@ -3853,9 +3871,9 @@
                 current_asmdata.getlabel(currlabel, alt_dbgline);
                 list.insertafter(tai_label.create(currlabel), hpend);
                 asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
    -            asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
    +            asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
                 asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
    -            asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,currlabel));
    +            asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,currlabel));
               end;
     
             { end sequence }
    @@ -3887,9 +3905,9 @@
             asmline.concat(tai_const.create_uleb128bit(get_file_index(infile)));
     
             asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
    -        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
    +        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
             asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
    -        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,nil));
    +        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,nil));
             asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
             asmline.concat(tai_const.Create_8bit(1));
             asmline.concat(tai_const.Create_8bit(DW_LNE_end_sequence));
    Index: compiler/aasmtai.pas
    ===================================================================
    --- compiler/aasmtai.pas	(revision 39317)
    +++ compiler/aasmtai.pas	(working copy)
    @@ -659,6 +659,7 @@
               constructor Create_int_codeptr_unaligned(_value: int64);
               constructor Create_int_dataptr(_value: int64);
               constructor Create_int_dataptr_unaligned(_value: int64);
    +          constructor Create_int_dataptr_unaligned(_value: int64; size: taiconst_type);
     {$ifdef i8086}
               constructor Create_seg_name(const name:string);
               constructor Create_dgroup;
    @@ -1878,7 +1879,24 @@
             value:=_value;
           end;
     
    +    constructor tai_const.Create_int_dataptr_unaligned(_value: int64; size: taiconst_type
    +      );
    +    begin
    +      inherited Create;
    +      typ:=ait_const;
    +{$ifdef i8086}
    +      if current_settings.x86memorymodel in x86_far_data_models then
    +        consttype:=aitconst_farptr
    +      else
    +{$endif i8086}
    +        consttype:=size;
    +      sym:=nil;
    +      endsym:=nil;
    +      symofs:=0;
    +      value:=_value;
    +    end;
     
    +
     {$ifdef i8086}
         constructor tai_const.Create_seg_name(const name:string);
           begin
    
    dbgdwarf-try-2.patch (14,839 bytes)
  • dbgdwarf.patch (2,873 bytes)
    Index: compiler/aasmtai.pas
    ===================================================================
    --- compiler/aasmtai.pas	(revision 40380)
    +++ compiler/aasmtai.pas	(working copy)
    @@ -678,6 +678,9 @@
               constructor Create_int_codeptr_unaligned(_value: int64);
               constructor Create_int_dataptr(_value: int64);
               constructor Create_int_dataptr_unaligned(_value: int64);
    +{$ifdef avr}
    +          constructor Create_int_dataptr_unaligned(_value: int64; size: taiconst_type);
    +{$endif}
     {$ifdef i8086}
               constructor Create_seg_name(const name:string);
               constructor Create_dgroup;
    @@ -1896,7 +1899,7 @@
               consttype:=aitconst_farptr
             else
     {$endif i8086}
    -          consttype:=aitconst_ptr_unaligned;
    +        consttype:=aitconst_ptr_unaligned;
             sym:=nil;
             endsym:=nil;
             symofs:=0;
    @@ -1904,6 +1907,20 @@
           end;
     
     
    +{$ifdef avr}
    +    constructor tai_const.Create_int_dataptr_unaligned(_value: int64;
    +      size: taiconst_type);
    +      begin
    +        inherited Create;
    +        typ:=ait_const;
    +        consttype:=size;
    +        sym:=nil;
    +        endsym:=nil;
    +        symofs:=0;
    +        value:=_value;
    +      end;
    +{$endif avr}
    +
     {$ifdef i8086}
         constructor tai_const.Create_seg_name(const name:string);
           begin
    Index: compiler/dbgdwarf.pas
    ===================================================================
    --- compiler/dbgdwarf.pas	(revision 40380)
    +++ compiler/dbgdwarf.pas	(working copy)
    @@ -48,6 +48,12 @@
           DbgBase;
     
         type
    +      {$ifdef avr}
    +      // re-map to larger types because of offsets required to distinguish different memory spaces
    +      puint = cardinal;
    +      pint = longint;
    +      {$endif avr}
    +
           { Tag names and codes.   }
           tdwarf_tag = (DW_TAG_padding := $00,DW_TAG_array_type := $01,
             DW_TAG_class_type := $02,DW_TAG_entry_point := $03,
    @@ -538,6 +544,11 @@
           { Implementation-defined range start.   }
           DW_LANG_hi_user = $ffff;
     
    +      {$ifdef avr}
    +      // More space required to include memory type offset
    +      aitconst_ptr_unaligned = aitconst_32bit_unaligned;
    +      {$endif avr}
    +
         type
           { Names and codes for macro information.   }
           tdwarf_macinfo_record_type = (DW_MACINFO_define := 1,DW_MACINFO_undef := 2,
    @@ -3125,7 +3136,12 @@
                      end;
                    *)
                    templist.concat(tai_const.create_8bit(3));
    +               {$ifdef avr}
    +               // Add $800000 to indicate that the address is in memory space
    +               templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset + $800000, aitconst_ptr_unaligned));
    +               {$else}
                    templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset));
    +               {$endif}
                    blocksize:=1+sizeof(puint);
                 end;
               toasm :
    
    dbgdwarf.patch (2,873 bytes)

Activities

Christo Crause

2018-06-30 21:48

reporter  

dbgdwarf-try-1.patch (13,326 bytes)
Index: compiler/dbgdwarf.pas
===================================================================
--- compiler/dbgdwarf.pas	(revision 39317)
+++ compiler/dbgdwarf.pas	(working copy)
@@ -48,6 +48,14 @@
       DbgBase;
 
     type
+      {$ifdef avr}
+      puint_d = cardinal;
+      pint_d = longint;
+      {$else avr}
+      puint_d = PUint;
+      pint_d = pint;
+      {$endif avr}
+
       { Tag names and codes.   }
       tdwarf_tag = (DW_TAG_padding := $00,DW_TAG_array_type := $01,
         DW_TAG_class_type := $02,DW_TAG_entry_point := $03,
@@ -396,11 +404,11 @@
         procedure appenddef_procvar(list:TAsmList;def:tprocvardef);override;
         procedure appendprocdef(list:TAsmList;def:tprocdef);override;
 
-        function  get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint): boolean;
+        function  get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint_d): boolean;
         procedure appendsym_var(list:TAsmList;sym:tabstractnormalvarsym);
-        procedure appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint; const flags: tdwarfvarsymflags);
+        procedure appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint_d; const flags: tdwarfvarsymflags);
         { used for fields and properties mapped to fields }
-        procedure appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint);
+        procedure appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint_d);
         procedure appendsym_const_member(list:TAsmList;sym:tconstsym;ismember:boolean);
 
         procedure beforeappendsym(list:TAsmList;sym:tsym);override;
@@ -538,6 +546,12 @@
       { Implementation-defined range start.   }
       DW_LANG_hi_user = $ffff;
 
+      {$ifdef avr}
+      aitconst_ptr_unaligned_d = aitconst_32bit_unaligned;
+      {$else avr}
+      aitconst_ptr_unaligned_d = aitconst_ptr_unaligned;
+      {$endif avr}
+
     type
       { Names and codes for macro information.   }
       tdwarf_macinfo_record_type = (DW_MACINFO_define := 1,DW_MACINFO_undef := 2,
@@ -1315,7 +1329,7 @@
       begin
         AddConstToAbbrev(ord(attr));
         AddConstToAbbrev(ord(DW_FORM_addr));
-        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned,sym));
+        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,sym));
       end;
 
     procedure TDebugInfoDwarf.append_labelentry_addr_ref(attr : tdwarf_attribute;sym : tasmsymbol);
@@ -1325,7 +1339,7 @@
         { DW_FORM_ref_addr is treated as 32-bit by Open Watcom on i8086 }
         current_asmdata.asmlists[al_dwarf_info].concat(tai_const.Create_type_sym(aitconst_32bit_unaligned,sym));
 {$else i8086}
-        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned,sym));
+        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,sym));
 {$endif i8086}
       end;
 
@@ -1822,8 +1836,8 @@
 
     procedure TDebugInfoDwarf.appenddef_array(list:TAsmList;def:tarraydef);
       var
-        size : PInt;
-        elesize : PInt;
+        size : PInt_d;
+        elesize : PInt_d;
         elestrideattr : tdwarf_attribute;
         labsym: tasmlabel;
       begin
@@ -2089,7 +2103,7 @@
             else
               current_asmdata.getaddrlabel(proc);
             append_entry(DW_TAG_structure_type,true,[
-              DW_AT_byte_size,DW_FORM_data1,2*sizeof(pint)
+              DW_AT_byte_size,DW_FORM_data1,2*sizeof(pint_d)
             ]);
             finish_entry;
 
@@ -2106,10 +2120,10 @@
             { self entry }
             append_entry(DW_TAG_member,false,[
               DW_AT_name,DW_FORM_string,'Self'#0,
-              DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(sizeof(pint))
+              DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(sizeof(pint_d))
               ]);
             current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
-            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(sizeof(pint)));
+            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(sizeof(pint_d)));
             append_labelentry_ref(DW_AT_type,def_dwarf_lab(class_tobject));
             finish_entry;
 
@@ -2255,7 +2269,7 @@
         procentry      : string;
         cc             : Tdwarf_calling_convention;
         st             : tsymtable;
-        vmtoffset      : pint;
+        vmtoffset      : pint_d;
         in_currentunit : boolean;
       begin
         { only write debug info for procedures defined in the current module,
@@ -2385,7 +2399,7 @@
                 current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_seg_name(procentry));
 {$endif i8086}
                 current_asmdata.asmlists[al_dwarf_aranges].Concat(
-                  tai_const.Create_rel_sym(aitconst_ptr_unaligned,current_asmdata.RefAsmSymbol(procentry,AT_FUNCTION),procendlabel));
+                  tai_const.Create_rel_sym(aitconst_ptr_unaligned_d,current_asmdata.RefAsmSymbol(procentry,AT_FUNCTION),procendlabel));
 {$ifdef i8086}
                 { bits 16..31 of length }
                 current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_16bit_unaligned(0));
@@ -2436,9 +2450,9 @@
       end;
 
 
-    function TDebugInfoDwarf.get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint): boolean;
+    function TDebugInfoDwarf.get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint_d): boolean;
       var
-        elesize : pint;
+        elesize : pint_d;
         currdef : tdef;
         indirection: boolean;
       begin
@@ -2528,7 +2542,7 @@
       end;
 
 
-    procedure TDebugInfoDwarf.appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint; const flags: tdwarfvarsymflags);
+    procedure TDebugInfoDwarf.appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint_d; const flags: tdwarfvarsymflags);
       var
         templist : TAsmList;
         blocksize,size_of_int : longint;
@@ -2618,15 +2632,15 @@
 { This is only a minimal change to at least be able to get a value
   in only one thread is present PM 2014-11-21, like for stabs format }
                         templist.concat(tai_const.create_8bit(ord(DW_OP_addr)));
-                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned,sym.mangledname,
-                          offset+sizeof(pint)));
-                        blocksize:=1+sizeof(puint);
+                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,
+                          offset+sizeof(pint_d)));
+                        blocksize:=1+sizeof(puint_d);
                       end
                     else
                       begin
                         templist.concat(tai_const.create_8bit(ord(DW_OP_addr)));
-                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned,sym.mangledname,offset));
-                        blocksize:=1+sizeof(puint);
+                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,offset));
+                        blocksize:=1+sizeof(puint_d);
 {$ifdef i8086}
                         segment_sym_name:=sym.mangledname;
                         has_segment_sym_name:=true;
@@ -2806,7 +2820,7 @@
       end;
 
 
-    procedure TDebugInfoDwarf.appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint);
+    procedure TDebugInfoDwarf.appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint_d);
       var
         bitoffset,
         fieldoffset,
@@ -2842,7 +2856,7 @@
             { possible, i.e., equivalent to gcc's                    }
             { __attribute__((__packed__)), which is also what gpc    }
             { does.                                                  }
-            fieldnatsize:=max(sizeof(pint),sym.vardef.size);
+            fieldnatsize:=max(sizeof(pint_d),sym.vardef.size);
             fieldoffset:=(sym.fieldoffset div (fieldnatsize*8)) * fieldnatsize;
             inc(fieldoffset,offset);
             bitoffset:=sym.fieldoffset mod (fieldnatsize*8);
@@ -3053,7 +3067,7 @@
       var
         symlist: ppropaccesslistitem;
         tosym: tabstractvarsym;
-        offset: pint;
+        offset: pint_d;
       begin
         if assigned(sym.propaccesslist[palt_read]) and
            not assigned(sym.propaccesslist[palt_read].procdef) then
@@ -3096,7 +3110,7 @@
         blocksize : longint;
         symlist : ppropaccesslistitem;
         tosym: tabstractvarsym;
-        offset: pint;
+        offset: pint_d;
         flags: tdwarfvarsymflags;
       begin
         templist:=TAsmList.create;
@@ -3113,13 +3127,13 @@
                *)
                templist.concat(tai_const.create_8bit(3));
                templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset));
-               blocksize:=1+sizeof(puint);
+               blocksize:=1+sizeof(puint_d);
             end;
           toasm :
             begin
               templist.concat(tai_const.create_8bit(3));
-              templist.concat(tai_const.create_type_name(aitconst_ptr_unaligned,sym.mangledname,0));
-              blocksize:=1+sizeof(puint);
+              templist.concat(tai_const.create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,0));
+              blocksize:=1+sizeof(puint_d);
             end;
           tovar:
             begin
@@ -3422,7 +3436,7 @@
             { no alignment/padding bytes on i8086 for Open Watcom compatibility }
 {$else i8086}
             { address_size }
-            current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint)));
+            current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint_d)));
             { segment_size }
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(0));
             { alignment }
@@ -3454,7 +3468,7 @@
             current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_abbrev0',AB_LOCAL,AT_METADATA,voidpointertype)));
 
         { address size }
-        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(pint)));
+        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(pint_d)));
 
         if (ds_dwarf_cpp in current_settings.debugswitches) then
           lang:=DW_LANG_C_plus_plus
@@ -3781,9 +3795,9 @@
                        (target_asm.id=as_solaris_as) then
                       begin
                         asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
-                        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
+                        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
                         asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
-                        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,currlabel));
+                        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,currlabel));
 {$ifdef i8086}
                         { on i8086 we also emit an Open Watcom-specific 'set segment' op }
                         asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
@@ -3853,9 +3867,9 @@
             current_asmdata.getlabel(currlabel, alt_dbgline);
             list.insertafter(tai_label.create(currlabel), hpend);
             asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
-            asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
+            asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
             asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
-            asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,currlabel));
+            asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,currlabel));
           end;
 
         { end sequence }
@@ -3887,9 +3901,9 @@
         asmline.concat(tai_const.create_uleb128bit(get_file_index(infile)));
 
         asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
-        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
+        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
         asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
-        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,nil));
+        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,nil));
         asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
         asmline.concat(tai_const.Create_8bit(1));
         asmline.concat(tai_const.Create_8bit(DW_LNE_end_sequence));
dbgdwarf-try-1.patch (13,326 bytes)

Christo Crause

2018-06-30 21:49

reporter   ~0109145

Attached dbgdwarf-try-1.patch works around the pointer size issue by redeclaring pint/puint and aitconst_ptr_unaligned fro the AVR target. This seems to fix the issue, not sure it is the best way.

Christo Crause

2018-07-01 14:57

reporter  

dbgdwarf-try-2.patch (14,839 bytes)
Index: compiler/dbgdwarf.pas
===================================================================
--- compiler/dbgdwarf.pas	(revision 39317)
+++ compiler/dbgdwarf.pas	(working copy)
@@ -48,6 +48,16 @@
       DbgBase;
 
     type
+      {$ifdef avr}
+      puint_d = cardinal;
+      pint_d = longint;
+      //puint_d = PUint;
+      //pint_d = pint;
+      {$else avr}
+      puint_d = PUint;
+      pint_d = pint;
+      {$endif avr}
+
       { Tag names and codes.   }
       tdwarf_tag = (DW_TAG_padding := $00,DW_TAG_array_type := $01,
         DW_TAG_class_type := $02,DW_TAG_entry_point := $03,
@@ -396,11 +406,11 @@
         procedure appenddef_procvar(list:TAsmList;def:tprocvardef);override;
         procedure appendprocdef(list:TAsmList;def:tprocdef);override;
 
-        function  get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint): boolean;
+        function  get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint_d): boolean;
         procedure appendsym_var(list:TAsmList;sym:tabstractnormalvarsym);
-        procedure appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint; const flags: tdwarfvarsymflags);
+        procedure appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint_d; const flags: tdwarfvarsymflags);
         { used for fields and properties mapped to fields }
-        procedure appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint);
+        procedure appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint_d);
         procedure appendsym_const_member(list:TAsmList;sym:tconstsym;ismember:boolean);
 
         procedure beforeappendsym(list:TAsmList;sym:tsym);override;
@@ -538,6 +548,13 @@
       { Implementation-defined range start.   }
       DW_LANG_hi_user = $ffff;
 
+      {$ifdef avr}
+      aitconst_ptr_unaligned_d = aitconst_32bit_unaligned;
+      //aitconst_ptr_unaligned_d = aitconst_ptr_unaligned;
+      {$else avr}
+      aitconst_ptr_unaligned_d = aitconst_ptr_unaligned;
+      {$endif avr}
+
     type
       { Names and codes for macro information.   }
       tdwarf_macinfo_record_type = (DW_MACINFO_define := 1,DW_MACINFO_undef := 2,
@@ -1315,7 +1332,7 @@
       begin
         AddConstToAbbrev(ord(attr));
         AddConstToAbbrev(ord(DW_FORM_addr));
-        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned,sym));
+        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,sym));
       end;
 
     procedure TDebugInfoDwarf.append_labelentry_addr_ref(attr : tdwarf_attribute;sym : tasmsymbol);
@@ -1325,7 +1342,7 @@
         { DW_FORM_ref_addr is treated as 32-bit by Open Watcom on i8086 }
         current_asmdata.asmlists[al_dwarf_info].concat(tai_const.Create_type_sym(aitconst_32bit_unaligned,sym));
 {$else i8086}
-        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned,sym));
+        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,sym));
 {$endif i8086}
       end;
 
@@ -1822,8 +1839,8 @@
 
     procedure TDebugInfoDwarf.appenddef_array(list:TAsmList;def:tarraydef);
       var
-        size : PInt;
-        elesize : PInt;
+        size : PInt_d;
+        elesize : PInt_d;
         elestrideattr : tdwarf_attribute;
         labsym: tasmlabel;
       begin
@@ -2089,7 +2106,7 @@
             else
               current_asmdata.getaddrlabel(proc);
             append_entry(DW_TAG_structure_type,true,[
-              DW_AT_byte_size,DW_FORM_data1,2*sizeof(pint)
+              DW_AT_byte_size,DW_FORM_data1,2*sizeof(pint_d)
             ]);
             finish_entry;
 
@@ -2106,10 +2123,10 @@
             { self entry }
             append_entry(DW_TAG_member,false,[
               DW_AT_name,DW_FORM_string,'Self'#0,
-              DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(sizeof(pint))
+              DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(sizeof(pint_d))
               ]);
             current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
-            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(sizeof(pint)));
+            current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(sizeof(pint_d)));
             append_labelentry_ref(DW_AT_type,def_dwarf_lab(class_tobject));
             finish_entry;
 
@@ -2255,7 +2272,7 @@
         procentry      : string;
         cc             : Tdwarf_calling_convention;
         st             : tsymtable;
-        vmtoffset      : pint;
+        vmtoffset      : pint_d;
         in_currentunit : boolean;
       begin
         { only write debug info for procedures defined in the current module,
@@ -2385,7 +2402,7 @@
                 current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_seg_name(procentry));
 {$endif i8086}
                 current_asmdata.asmlists[al_dwarf_aranges].Concat(
-                  tai_const.Create_rel_sym(aitconst_ptr_unaligned,current_asmdata.RefAsmSymbol(procentry,AT_FUNCTION),procendlabel));
+                  tai_const.Create_rel_sym(aitconst_ptr_unaligned_d,current_asmdata.RefAsmSymbol(procentry,AT_FUNCTION),procendlabel));
 {$ifdef i8086}
                 { bits 16..31 of length }
                 current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_16bit_unaligned(0));
@@ -2436,9 +2453,9 @@
       end;
 
 
-    function TDebugInfoDwarf.get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint): boolean;
+    function TDebugInfoDwarf.get_symlist_sym_offset(symlist: ppropaccesslistitem; out sym: tabstractvarsym; out offset: pint_d): boolean;
       var
-        elesize : pint;
+        elesize : pint_d;
         currdef : tdef;
         indirection: boolean;
       begin
@@ -2528,7 +2545,7 @@
       end;
 
 
-    procedure TDebugInfoDwarf.appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint; const flags: tdwarfvarsymflags);
+    procedure TDebugInfoDwarf.appendsym_var_with_name_type_offset(list:TAsmList; sym:tabstractnormalvarsym; const name: string; def: tdef; offset: pint_d; const flags: tdwarfvarsymflags);
       var
         templist : TAsmList;
         blocksize,size_of_int : longint;
@@ -2618,15 +2635,15 @@
 { This is only a minimal change to at least be able to get a value
   in only one thread is present PM 2014-11-21, like for stabs format }
                         templist.concat(tai_const.create_8bit(ord(DW_OP_addr)));
-                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned,sym.mangledname,
-                          offset+sizeof(pint)));
-                        blocksize:=1+sizeof(puint);
+                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,
+                          offset+sizeof(pint_d)));
+                        blocksize:=1+sizeof(puint_d);
                       end
                     else
                       begin
                         templist.concat(tai_const.create_8bit(ord(DW_OP_addr)));
-                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned,sym.mangledname,offset));
-                        blocksize:=1+sizeof(puint);
+                        templist.concat(tai_const.Create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,offset));
+                        blocksize:=1+sizeof(puint_d);
 {$ifdef i8086}
                         segment_sym_name:=sym.mangledname;
                         has_segment_sym_name:=true;
@@ -2806,7 +2823,7 @@
       end;
 
 
-    procedure TDebugInfoDwarf.appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint);
+    procedure TDebugInfoDwarf.appendsym_fieldvar_with_name_offset(list:TAsmList;sym: tfieldvarsym;const name: string; def: tdef; offset: pint_d);
       var
         bitoffset,
         fieldoffset,
@@ -2842,7 +2859,7 @@
             { possible, i.e., equivalent to gcc's                    }
             { __attribute__((__packed__)), which is also what gpc    }
             { does.                                                  }
-            fieldnatsize:=max(sizeof(pint),sym.vardef.size);
+            fieldnatsize:=max(sizeof(pint_d),sym.vardef.size);
             fieldoffset:=(sym.fieldoffset div (fieldnatsize*8)) * fieldnatsize;
             inc(fieldoffset,offset);
             bitoffset:=sym.fieldoffset mod (fieldnatsize*8);
@@ -3053,7 +3070,7 @@
       var
         symlist: ppropaccesslistitem;
         tosym: tabstractvarsym;
-        offset: pint;
+        offset: pint_d;
       begin
         if assigned(sym.propaccesslist[palt_read]) and
            not assigned(sym.propaccesslist[palt_read].procdef) then
@@ -3096,7 +3113,7 @@
         blocksize : longint;
         symlist : ppropaccesslistitem;
         tosym: tabstractvarsym;
-        offset: pint;
+        offset: pint_d;
         flags: tdwarfvarsymflags;
       begin
         templist:=TAsmList.create;
@@ -3112,14 +3129,15 @@
                  end;
                *)
                templist.concat(tai_const.create_8bit(3));
-               templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset));
-               blocksize:=1+sizeof(puint);
+               //templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset));
+               templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset, aitconst_ptr_unaligned_d));
+               blocksize:=1+sizeof(puint_d);
             end;
           toasm :
             begin
               templist.concat(tai_const.create_8bit(3));
-              templist.concat(tai_const.create_type_name(aitconst_ptr_unaligned,sym.mangledname,0));
-              blocksize:=1+sizeof(puint);
+              templist.concat(tai_const.create_type_name(aitconst_ptr_unaligned_d,sym.mangledname,0));
+              blocksize:=1+sizeof(puint_d);
             end;
           tovar:
             begin
@@ -3422,7 +3440,7 @@
             { no alignment/padding bytes on i8086 for Open Watcom compatibility }
 {$else i8086}
             { address_size }
-            current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint)));
+            current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint_d)));
             { segment_size }
             current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(0));
             { alignment }
@@ -3454,7 +3472,7 @@
             current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_abbrev0',AB_LOCAL,AT_METADATA,voidpointertype)));
 
         { address size }
-        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(pint)));
+        current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(pint_d)));
 
         if (ds_dwarf_cpp in current_settings.debugswitches) then
           lang:=DW_LANG_C_plus_plus
@@ -3781,9 +3799,9 @@
                        (target_asm.id=as_solaris_as) then
                       begin
                         asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
-                        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
+                        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
                         asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
-                        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,currlabel));
+                        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,currlabel));
 {$ifdef i8086}
                         { on i8086 we also emit an Open Watcom-specific 'set segment' op }
                         asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
@@ -3853,9 +3871,9 @@
             current_asmdata.getlabel(currlabel, alt_dbgline);
             list.insertafter(tai_label.create(currlabel), hpend);
             asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
-            asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
+            asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
             asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
-            asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,currlabel));
+            asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,currlabel));
           end;
 
         { end sequence }
@@ -3887,9 +3905,9 @@
         asmline.concat(tai_const.create_uleb128bit(get_file_index(infile)));
 
         asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
-        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint)));
+        asmline.concat(tai_const.create_uleb128bit(1+sizeof(pint_d)));
         asmline.concat(tai_const.create_8bit(DW_LNE_set_address));
-        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned,nil));
+        asmline.concat(tai_const.create_type_sym(aitconst_ptr_unaligned_d,nil));
         asmline.concat(tai_const.create_8bit(DW_LNS_extended_op));
         asmline.concat(tai_const.Create_8bit(1));
         asmline.concat(tai_const.Create_8bit(DW_LNE_end_sequence));
Index: compiler/aasmtai.pas
===================================================================
--- compiler/aasmtai.pas	(revision 39317)
+++ compiler/aasmtai.pas	(working copy)
@@ -659,6 +659,7 @@
           constructor Create_int_codeptr_unaligned(_value: int64);
           constructor Create_int_dataptr(_value: int64);
           constructor Create_int_dataptr_unaligned(_value: int64);
+          constructor Create_int_dataptr_unaligned(_value: int64; size: taiconst_type);
 {$ifdef i8086}
           constructor Create_seg_name(const name:string);
           constructor Create_dgroup;
@@ -1878,7 +1879,24 @@
         value:=_value;
       end;
 
+    constructor tai_const.Create_int_dataptr_unaligned(_value: int64; size: taiconst_type
+      );
+    begin
+      inherited Create;
+      typ:=ait_const;
+{$ifdef i8086}
+      if current_settings.x86memorymodel in x86_far_data_models then
+        consttype:=aitconst_farptr
+      else
+{$endif i8086}
+        consttype:=size;
+      sym:=nil;
+      endsym:=nil;
+      symofs:=0;
+      value:=_value;
+    end;
 
+
 {$ifdef i8086}
     constructor tai_const.Create_seg_name(const name:string);
       begin
dbgdwarf-try-2.patch (14,839 bytes)

Christo Crause

2018-07-01 15:07

reporter   ~0109156

The first patch missed a call to tai_const.create_int_dataptr_unaligned(sym.addroffset)) which is set to aitconst_16bit_unaligned inside aasmtai.

In the 2nd patch an extra create_int_dataptr_unaligned method is declared with a size parameter to specify the size of the pointer.

Could perhaps have made it specifically create_int_dataptr32_unaligned since it is only used by dbgdwarf for AVR target.

Christo Crause

2018-11-28 18:16

reporter  

dbgdwarf.patch (2,873 bytes)
Index: compiler/aasmtai.pas
===================================================================
--- compiler/aasmtai.pas	(revision 40380)
+++ compiler/aasmtai.pas	(working copy)
@@ -678,6 +678,9 @@
           constructor Create_int_codeptr_unaligned(_value: int64);
           constructor Create_int_dataptr(_value: int64);
           constructor Create_int_dataptr_unaligned(_value: int64);
+{$ifdef avr}
+          constructor Create_int_dataptr_unaligned(_value: int64; size: taiconst_type);
+{$endif}
 {$ifdef i8086}
           constructor Create_seg_name(const name:string);
           constructor Create_dgroup;
@@ -1896,7 +1899,7 @@
           consttype:=aitconst_farptr
         else
 {$endif i8086}
-          consttype:=aitconst_ptr_unaligned;
+        consttype:=aitconst_ptr_unaligned;
         sym:=nil;
         endsym:=nil;
         symofs:=0;
@@ -1904,6 +1907,20 @@
       end;
 
 
+{$ifdef avr}
+    constructor tai_const.Create_int_dataptr_unaligned(_value: int64;
+      size: taiconst_type);
+      begin
+        inherited Create;
+        typ:=ait_const;
+        consttype:=size;
+        sym:=nil;
+        endsym:=nil;
+        symofs:=0;
+        value:=_value;
+      end;
+{$endif avr}
+
 {$ifdef i8086}
     constructor tai_const.Create_seg_name(const name:string);
       begin
Index: compiler/dbgdwarf.pas
===================================================================
--- compiler/dbgdwarf.pas	(revision 40380)
+++ compiler/dbgdwarf.pas	(working copy)
@@ -48,6 +48,12 @@
       DbgBase;
 
     type
+      {$ifdef avr}
+      // re-map to larger types because of offsets required to distinguish different memory spaces
+      puint = cardinal;
+      pint = longint;
+      {$endif avr}
+
       { Tag names and codes.   }
       tdwarf_tag = (DW_TAG_padding := $00,DW_TAG_array_type := $01,
         DW_TAG_class_type := $02,DW_TAG_entry_point := $03,
@@ -538,6 +544,11 @@
       { Implementation-defined range start.   }
       DW_LANG_hi_user = $ffff;
 
+      {$ifdef avr}
+      // More space required to include memory type offset
+      aitconst_ptr_unaligned = aitconst_32bit_unaligned;
+      {$endif avr}
+
     type
       { Names and codes for macro information.   }
       tdwarf_macinfo_record_type = (DW_MACINFO_define := 1,DW_MACINFO_undef := 2,
@@ -3125,7 +3136,12 @@
                  end;
                *)
                templist.concat(tai_const.create_8bit(3));
+               {$ifdef avr}
+               // Add $800000 to indicate that the address is in memory space
+               templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset + $800000, aitconst_ptr_unaligned));
+               {$else}
                templist.concat(tai_const.create_int_dataptr_unaligned(sym.addroffset));
+               {$endif}
                blocksize:=1+sizeof(puint);
             end;
           toasm :
dbgdwarf.patch (2,873 bytes)

Christo Crause

2018-11-28 18:28

reporter   ~0112248

I noticed that variables with absolute addresses where also not correctly included in the debug information. To fix this I added $800000 to the debug address of absolute address references to indicate that the address is in memory space, not code space.

Refactored previous patch to use type aliases only for AVR, so no code changes for other targets.

The previous 2 patches can be ignored as all functionality is captured in the last patch.

Dimitrios Chr. Ioannidis

2019-06-10 08:19

reporter   ~0116653

I confirm that with this patch I can finally use Lazarus and gdbmidebugger to debug a real target .

Christo Crause

2019-07-26 20:58

reporter   ~0117423

Thanks Jeppe.

Issue History

Date Modified Username Field Change
2018-06-27 08:03 Christo Crause New Issue
2018-06-30 21:48 Christo Crause File Added: dbgdwarf-try-1.patch
2018-06-30 21:49 Christo Crause Note Added: 0109145
2018-07-01 14:57 Christo Crause File Added: dbgdwarf-try-2.patch
2018-07-01 15:07 Christo Crause Note Added: 0109156
2018-11-28 18:16 Christo Crause File Added: dbgdwarf.patch
2018-11-28 18:28 Christo Crause Note Added: 0112248
2019-06-10 08:19 Dimitrios Chr. Ioannidis Note Added: 0116653
2019-06-10 13:08 Dimitrios Chr. Ioannidis Tag Attached: AVR
2019-07-25 15:24 Jeppe Johansen Assigned To => Jeppe Johansen
2019-07-25 15:24 Jeppe Johansen Status new => resolved
2019-07-25 15:24 Jeppe Johansen Resolution open => fixed
2019-07-25 15:24 Jeppe Johansen Fixed in Version => 3.3.1
2019-07-25 15:24 Jeppe Johansen Fixed in Revision => 42493
2019-07-25 15:24 Jeppe Johansen FPCTarget => -
2019-07-26 20:58 Christo Crause Status resolved => closed
2019-07-26 20:58 Christo Crause Note Added: 0117423