[fpc-devel] [AVR] Debugging objects

Dimitrios Chr. Ioannidis d.ioannidis at nephelae.eu
Sat Sep 24 09:31:54 CEST 2022


Hi,

   it seems that there is another DWARF bug regarding objects in units.

Using MPLAB SNAP, ATBACKEND and gdb ( 8.3 ) session :

-----------------------
Reading symbols from avr_object_debug_test.elf...
(gdb) target remote :2345
Remote debugging using :2345
0x00000000 in _START ()
(gdb) monitor tool snap
(gdb) monitor device atmega328p debugwire
(gdb) load
Loading section .text, size 0x74a lma 0x0
Loading section .data, size 0x5e lma 0x74a
Start address 0x0, load size 1960
Transfer rate: 688 bytes/sec, 980 bytes/write.
(gdb) break main
Breakpoint 1 at 0xa2: file avr_object_debug_test.pas, line 10.
(gdb) monitor reset
(gdb) c
Continuing.

Breakpoint 1, $main () at avr_object_debug_test.pas:10
10        TestObj.DoSomething;
(gdb) s
UTESTOBJs_sTTESTOBJ_s__ss_DOSOMETHING () at utestobj.pas:16
16        x := 5;
(gdb) print x
No symbol "x" in current context.
(gdb) s
17        Inc(i);
(gdb) print i
$1 = 7
(gdb) print x
No symbol "x" in current context.
(gdb) s
18        x := i;
(gdb) print x
No symbol "x" in current context.
(gdb) print i
$2 = 7
(gdb)
-----------------------


Compiled with avr cross compiler 3.2.2 and 3.2.3 ( builded 23/9/2022 ) 
with "-Tembedded -Pavr -MObjFPC -Sai -CirotR -O1 -gw3 -Xg -a -al -Xe -Xm 
-Sm -WpATMEGA328P -CpAVR5 -godwarfsets -dF_CPU:=16000000 
avr_object_debug_test.pas"

-----------------------
program avr_object_debug_test;

uses
   utestobj;

var
   TestObj: TTestObj;

begin
   TestObj.DoSomething;
end.
-----------------------

-----------------------
unit utestobj;

interface

type
   TTestObj = object
     procedure DoSomething;
   end;

implementation

procedure TTestObj.DoSomething;
var
   i, x: SizeInt;
begin
   x := 5;
   Inc(i);
   x := i;
end;

end.
-----------------------


utestobj unit dwarf Info

-----------------------
<0><1061>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <1062>   DW_AT_name        : utestobj.pas
    <106f>   DW_AT_producer    : Free Pascal 3.2.3 2022/09/23
    <108c>   DW_AT_comp_dir    : 
G:/Programming/dimitris/Projects/fpc_avr_bugs/debug_objects/
    <10c9>   DW_AT_language    : 9      (ANSI Pascal)
    <10ca>   DW_AT_identifier_case: 3   (case_insensitive)
    <10cb>   DW_AT_stmt_list   : 0xe3
    <10cf>   DW_AT_low_pc      : 0x6f6
    <10d3>   DW_AT_high_pc     : 0x74a
<1><10d7>: Abbrev Number: 2 (DW_TAG_typedef)
    <10d8>   DW_AT_name        : TTestObj
    <10e1>   DW_AT_type        : <0x10e5>
<1><10e5>: Abbrev Number: 3 (DW_TAG_structure_type)
    <10e6>   DW_AT_name        : TTestObj
    <10ef>   DW_AT_byte_size   : 0
<2><10f0>: Abbrev Number: 0
<1><10f1>: Abbrev Number: 4 (DW_TAG_reference_type)
    <10f2>   DW_AT_type        : <0x10d7>
<1><10f6>: Abbrev Number: 2 (DW_TAG_typedef)
    <10f7>   DW_AT_name        : $vmtdef$TTESTOBJ
    <1108>   DW_AT_type        : <0x110c>
<1><110c>: Abbrev Number: 3 (DW_TAG_structure_type)
    <110d>   DW_AT_name        : $VMTDEF$TTESTOBJ
    <111e>   DW_AT_byte_size   : 8
<2><111f>: Abbrev Number: 0
<1><1120>: Abbrev Number: 4 (DW_TAG_reference_type)
    <1121>   DW_AT_type        : <0x10f6>
<1><1125>: Abbrev Number: 2 (DW_TAG_typedef)
    <1126>   DW_AT_name        : $rttidef$INIT_$UTESTOBJ_$$_TTESTOBJ
    <114a>   DW_AT_type        : <0x114e>
<1><114e>: Abbrev Number: 3 (DW_TAG_structure_type)
    <114f>   DW_AT_name        : $RTTIDEF$INIT_$UTESTOBJ_$$_TTESTOBJ
    <1173>   DW_AT_byte_size   : 24
<2><1174>: Abbrev Number: 0
<1><1175>: Abbrev Number: 4 (DW_TAG_reference_type)
    <1176>   DW_AT_type        : <0x1125>
<1><117a>: Abbrev Number: 2 (DW_TAG_typedef)
    <117b>   DW_AT_name        : $rttidef$RTTI_$UTESTOBJ_$$_TTESTOBJ
    <119f>   DW_AT_type        : <0x11a3>
<1><11a3>: Abbrev Number: 3 (DW_TAG_structure_type)
    <11a4>   DW_AT_name        : $RTTIDEF$RTTI_$UTESTOBJ_$$_TTESTOBJ
    <11c8>   DW_AT_byte_size   : 20
<2><11c9>: Abbrev Number: 0
<1><11ca>: Abbrev Number: 4 (DW_TAG_reference_type)
    <11cb>   DW_AT_type        : <0x117a>
<1><11cf>: Abbrev Number: 0
-----------------------


regards,

-- 
Dimitrios Chr. Ioannidis


More information about the fpc-devel mailing list