Recent

Author Topic: HOW TO EDIT/DEBUG FPC RTL  (Read 1755 times)

cai

  • New Member
  • *
  • Posts: 41
HOW TO EDIT/DEBUG FPC RTL
« on: July 14, 2020, 12:34:32 pm »
I create a project,  put a button and memo,  compile with aarch64-linux, when I startup, raise exception: EReadError, Error reading Form1.Height: Access violation.
I think there are some error in TReader.ReadData or res-data(lfm after compile)?  now I need to edit & debug TReader to fix it, is there a short way?
« Last Edit: July 14, 2020, 12:51:42 pm by cai »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: HOW TO EDIT/DEBUG FPC RTL
« Reply #1 on: July 14, 2020, 12:37:38 pm »
A quick fix sometimes can be running under gdb
Quote
gdb ./project1

and when an exception happens, type

Quote
bt

to get a backtrace

cai

  • New Member
  • *
  • Posts: 41
Re: HOW TO EDIT/DEBUG FPC RTL
« Reply #2 on: July 14, 2020, 12:51:07 pm »
A quick fix sometimes can be running under gdb
Quote
gdb ./project1

and when an exception happens, type

Quote
bt

to get a backtrace


thanks! here is backtrace
=========================
(gdb) run
Starting program: /home/uos/Desktop/Winuim/project1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00000000005a8114 in CONTROLS$_$TCONTROL_$__$$_FOREIGNANCHORSIDECHANGED$TANCHORSIDE$TANCHORSIDECHANGEOPERATION ()
(gdb) bt
#0  0x00000000005a8114 in CONTROLS$_$TCONTROL_$__$$_FOREIGNANCHORSIDECHANGED$TANCHORSIDE$TANCHORSIDECHANGEOPERATION ()
#1  0x000000000077527c in IMGLIST$_$TCUSTOMIMAGELIST_$__$$_SETHEIGHT$LONGINT ()
#2  0x000000000053aac0 in TYPINFO_$$_SETORDPROP$TOBJECT$PPROPINFO$INT64 ()
#3  0x00000000005004d8 in CLASSES$_$TREADER_$__$$_READPROPVALUE$TPERSISTENT$POINTER ()
#4  0x00000000004ffe40 in CLASSES$_$TREADER_$__$$_READPROPERTY$TPERSISTENT ()
#5  0x00000000004ff204 in CLASSES$_$TREADER_$__$$_READDATA$TCOMPONENT ()
#6  0x00000000004f3950 in CLASSES$_$TCOMPONENT_$__$$_READSTATE$TREADER ()
#7  0x00000000005aa2fc in CONTROLS$_$TCONTROL_$__$$_READSTATE$TREADER ()
#8  0x0000000000500c94 in CLASSES$_$TREADER_$__$$_READROOTCOMPONENT$TCOMPONENT$$TCOMPONENT ()
#9  0x00000000006b1b54 in LRESOURCES$_$INITLAZRESOURCECOMPONENT$TCOMPONENT$TCLASS$$BOOLEAN_$$_INITCOMPONENT$TCLASS$$BOOLEAN ()
#10 0x00000000006b1934 in LRESOURCES_$$_INITLAZRESOURCECOMPONENT$TCOMPONENT$TCLASS$$BOOLEAN ()
#11 0x00000000006a9118 in LRESOURCES_$$_INITRESOURCECOMPONENT$TCOMPONENT$TCLASS$$BOOLEAN ()
#12 0x0000000000499f7c in FORMS$_$TCUSTOMFORM_$__$$_PROCESSRESOURCE ()
#13 0x0000000000499e10 in FORMS$_$TCUSTOMFORM_$__$$_CREATE$TCOMPONENT$$TCUSTOMFORM ()
#14 0x000000000049cfcc in FORMS$_$TFORM_$__$$_CREATE$TCOMPONENT$$TFORM ()
--Type <RET> for more, q to quit, c to continue without paging--ret
formal ()
#16 0x000000000045f0f8 in main () at project1.lpr:18

=====================================
messages without gdb

./project1
[FORMS.PP] ExceptionOccurred
  Sender=EReadError
  Exception=Error reading Form1.Height: Access violation
  Stack trace:
  $00000000004FFF74
  $00000000004F3950
  $00000000005AA2FC
  $0000000000500C94
  $00000000006B1B54
  $00000000006B1934
  $00000000006A9118
  $0000000000499F7C
  $0000000000499E10
  $000000000049CFCC
  $00000000004A7184
  $000000000045F0F8  main,  line 18 of project1.lpr
  $0000FFFFAF805D24
  $000000000045EFC8
TApplication.HandleException Error reading Form1.Height: Access violation
  Stack trace:
  $00000000004FFF74
  $00000000004F3950
  $00000000005AA2FC
  $0000000000500C94
  $00000000006B1B54
  $00000000006B1934
  $00000000006A9118
  $0000000000499F7C
  $0000000000499E10
  $000000000049CFCC
  $00000000004A7184
  $000000000045F0F8  main,  line 18 of project1.lpr
  $0000FFFFAF805D24
  $000000000045EFC8

« Last Edit: July 14, 2020, 01:07:29 pm by cai »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: HOW TO EDIT/DEBUG FPC RTL
« Reply #3 on: July 14, 2020, 12:59:32 pm »
Looks to me that setting a property (height) via setheight triggers an anchor property change that should have been under csloading?

I'm no LCL/VCL expert though, but this is not in the streaming, but in the classes reacting wrongly to it.

cai

  • New Member
  • *
  • Posts: 41
Re: HOW TO EDIT/DEBUG FPC RTL
« Reply #4 on: July 14, 2020, 01:22:44 pm »
Looks to me that setting a property (height) via setheight triggers an anchor property change that should have been under csloading?

I'm no LCL/VCL expert though, but this is not in the streaming, but in the classes reacting wrongly to it.

thank,
according to InitLazResourceComponent:
begin
  if Instance.ComponentState * [csLoading, csInline] <> []
  then begin
    // global loading not needed
    Result := InitComponent(Instance.ClassType);
  end
  else try
    BeginGlobalLoading;
    Result := InitComponent(Instance.ClassType);
    NotifyGlobalLoading;
  finally
    EndGlobalLoading;
  end;
end;

is csloading still need to be set?

i think this log is problem too,

#1  0x000000000077527c in IMGLIST$_$TCUSTOMIMAGELIST_$__$$_SETHEIGHT$LONGINT ()
#2  0x000000000053aac0 in TYPINFO_$$_SETORDPROP$TOBJECT$PPROPINFO$INT64 ()

at this time, the classname of SETHEIGHT should be TForm? Imagelist properties is not in the lfm-resource.


besides, this version of fpc src, I have compiled to x86_64-ubuntu, mipsel-linux with the same project, and is no problem.
so I guess maybe aarch64 rtti-typesize-process or something error?  console-application is no problem too.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: HOW TO EDIT/DEBUG FPC RTL
« Reply #5 on: July 14, 2020, 01:48:01 pm »
besides, this version of fpc src, I have compiled to x86_64-ubuntu, mipsel-linux with the same project, and is no problem.
so I guess maybe aarch64 rtti-typesize-process or something error?  console-application is no problem too.

Are you using FPC 3.2 or trunk?

cai

  • New Member
  • *
  • Posts: 41
Re: HOW TO EDIT/DEBUG FPC RTL
« Reply #6 on: July 14, 2020, 01:50:33 pm »
maybe I found a way to edit&debug rtl-classes now.

1) copy sub-files fo 'fpcsrc\rtl\objpas\classes' to the root-dir of project
2) copy fpcsrc\rtl\unix\classes.pp, tthread.inc to the root-dir of project
3) now i can edit&compile the files of classes.pp

just like in delphi.

cai

  • New Member
  • *
  • Posts: 41
Re: HOW TO EDIT/DEBUG FPC RTL
« Reply #7 on: July 14, 2020, 01:52:44 pm »
besides, this version of fpc src, I have compiled to x86_64-ubuntu, mipsel-linux with the same project, and is no problem.
so I guess maybe aarch64 rtti-typesize-process or something error?  console-application is no problem too.

Are you using FPC 3.2 or trunk?

i am using codetyphon, i think it is a modification of FPC, this is the message of codetyphon
================================
This is a modification of Freepascal (FPC) Source
version 3.1.1 SVN trunk Rev 35374

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: HOW TO EDIT/DEBUG FPC RTL
« Reply #8 on: July 14, 2020, 02:01:56 pm »
i am using codetyphon, i think it is a modification of FPC, this is the message of codetyphon
================================
This is a modification of Freepascal (FPC) Source
version 3.1.1 SVN trunk Rev 35374

You should test with either 3.2 or Trunk then, cause it could be that some work on RTTI broke things temporarily, but I definitely won't investigate that in some old, inbetween version.

cai

  • New Member
  • *
  • Posts: 41
Re: HOW TO EDIT/DEBUG FPC RTL
« Reply #9 on: July 14, 2020, 07:12:19 pm »
i am using codetyphon, i think it is a modification of FPC, this is the message of codetyphon
================================
This is a modification of Freepascal (FPC) Source
version 3.1.1 SVN trunk Rev 35374

You should test with either 3.2 or Trunk then, cause it could be that some work on RTTI broke things temporarily, but I definitely won't investigate that in some old, inbetween version.

ok, i found CodeTyphon is using version 3.3.1 FPC now, i will test it.

This is a modification of Freepascal (FPC) Source
version 3.3.1 SVN trunk

cai

  • New Member
  • *
  • Posts: 41
Re: HOW TO EDIT/DEBUG FPC RTL
« Reply #10 on: July 15, 2020, 06:08:34 am »
i am using codetyphon, i think it is a modification of FPC, this is the message of codetyphon
================================
This is a modification of Freepascal (FPC) Source
version 3.1.1 SVN trunk Rev 35374

You should test with either 3.2 or Trunk then, cause it could be that some work on RTTI broke things temporarily, but I definitely won't investigate that in some old, inbetween version.

test ok with FPC 3.3.1

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: HOW TO EDIT/DEBUG FPC RTL
« Reply #11 on: July 15, 2020, 09:45:55 am »
test ok with FPC 3.3.1

Thought so ;)

 

TinyPortal © 2005-2018