Recent

Author Topic: Scintilla Pascal  (Read 16757 times)

Anonymous

  • Guest
Scintilla Pascal
« on: June 08, 2005, 04:42:23 pm »
Hi all,
I'm trying to port Scintilla Pascal suite to Lazarus. At this time I need some debug, because when I put a Scintilla Memo on the form, Lazarus (sadly) freezes. My question is: how to debug a component?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Scintilla Pascal
« Reply #1 on: June 08, 2005, 05:39:16 pm »
2 options

1) run lazarus (=debugee) within lazarus (=debugger), put the memo on a form of the debugee
2) run lazarus (=debugee) within gdb (=debugger), put the memo on a form of the debugee

and see what is happening
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Legolas

  • Full Member
  • ***
  • Posts: 117
    • http://itaprogaming.free.fr
Scintilla Pascal
« Reply #2 on: June 09, 2005, 02:05:17 pm »
Ok, done  :)

At the freezing-time the gdb says:

Code: [Select]

Program received signal SIGSEGV, Segmentation fault.
$00000000 in ?? () from


Doing a bt:
Code: [Select]

#0  $00000000 in ?? () from
#1  $00892a70 in TSCINTILLA__SPERFORM (MSG=2030, WPARAM=0, LPARAM=0,
    this=$28cc380) at SciLexer.pas:3257
#2  $0088df31 in TSCINTILLA__GETEOLMODE (this=$28cc380) at SciLexer.pas:898
#3  $0089345d in TSCINTILLA__GETEOLSTYLE (this=$28cc380) at SciLexer.pas:3490
#4  $004852e5 in GETORDPROP (INSTANCE=$28cc380, PROPINFO=$b5bef6)
    at typinfo.pp:763
#5  $00568f89 in TPROPERTYEDITOR__GETORDVALUEAT (INDEX=0, this=$258d7e4)
    at PropEdits.pp:2357
#6  $00568f56 in TPROPERTYEDITOR__GETORDVALUE (this=$258d7e4)
    at PropEdits.pp:2352
#7  $0056aabf in TORDINALPROPERTYEDITOR__GETVALUE (this=$258d7e4)
    at PropEdits.pp:2838
#8  $00569967 in TPROPERTYEDITOR__GETVISUALVALUE (this=$258d7e4)
    at PropEdits.pp:2493
#9  $0056a95c in TPROPERTYEDITOR__ISNOTDEFAULTVALUE (this=$258d7e4)
    at PropEdits.pp:2806
#10 $0055e2e7 in TOICUSTOMPROPERTYGRID__PAINTROW (AROW=6, this=$27faa28)
    at ObjectInspector.pp:1893
#11 $0055e89e in TOICUSTOMPROPERTYGRID__DOPAINT (PAINTONLYCHANGEDVALUES=false,
    this=$27faa28) at ObjectInspector.pp:1924
#12 $0055ea73 in TOICUSTOMPROPERTYGRID__PAINT (this=$27faa28)
    at ObjectInspector.pp:1949
#13 $004bca69 in TCUSTOMCONTROL__PAINTWINDOW (DC=50401658, this=$27faa28)
    at customcontrol.inc:114
#14 $004afab6 in TWINCONTROL__PAINTHANDLER (THEMESSAGE=
      {MSG = 1056, DC = 50401658, PAINTSTRUCT = $6fbac, RESULT = 42779520},
    this=$27faa28) at wincontrol.inc:1689
#15 $004b27a3 in TWINCONTROL__WMPAINT (MSG=
      {MSG = 1056, DC = 50401658, PAINTSTRUCT = $6fbac, RESULT = 42779520},
    this=$27faa28) at wincontrol.inc:3314
#16 $004bc9ba in TCUSTOMCONTROL__WMPAINT (MESSAGE=
      {MSG = 1056, DC = 50401658, PAINTSTRUCT = $6fbac, RESULT = 42779520},
    this=$27faa28) at customcontrol.inc:94
#17 $0040990b in TOBJECT__DISPATCH (MESSAGE=void, this=$27faa28)
    at objpas.inc:467
#18 $004b7f52 in TCONTROL__WNDPROC (THEMESSAGE=
      {MSG = 1056, WPARAM = 50401658, LPARAM = 457644, RESULT = 42779520, WPARAM
LO = 4474, WPARAMHI = 769, LPARAMLO = 64428, LPARAMHI = 6, RESULTLO = 50048, RES
ULTHI = 652}, this=$27faa28) at control.inc:1481
#19 $004b08b1 in TWINCONTROL__WNDPROC (MESSAGE=
      {MSG = 1056, WPARAM = 50401658, LPARAM = 457644, RESULT = 42779520, WPARAM
LO = 4474, WPARAMHI = 769, LPARAMLO = 64428, LPARAMHI = 6, RESULTLO = 50048, RES
ULTHI = 652}, this=$27faa28) at wincontrol.inc:2135
#20 $0052d1df in DELIVERMESSAGE (TARGET=$27faa28, MESSAGE=void)
    at Win32Proc.pp:527
#21 $0048cd90 in SENDPAINTMESSAGE (parentfp=$6fda0) at win32callback.inc:303
#22 $0048baa1 in WINDOWPROC (WINDOW=3343060, MSG=15, WPARAM=0, LPARAM=0)
    at win32callback.inc:1089
#23 $77e3a3d0 in $MMSYSTEM$_L596 ()
#24 $77e14750 in $MMSYSTEM$_L596 ()
#25 $77e155b0 in $MMSYSTEM$_L596 ()
#26 $7847ff57 in ?? ()
#27 $77e15b77 in $MMSYSTEM$_L596 ()
#28 $0041e82b in TAPPLICATION__HANDLEMESSAGE (this=$b7a14)
    at application.inc:861
#29 $0041eba8 in RUNMESSAGE (parentfp=$6ffa8) at application.inc:969
#30 $0041eafb in TAPPLICATION__RUN (this=$b7a14) at application.inc:980
#31 $00401146 in main () at lazarus.pp:84

I don't know how to resolve this problem... The component's constructor seems ok, and all objects are created... Some suggestions?  :?:

PS. In the previous message I have forgotten to log in, sorry...  :oops:

Forest

  • New Member
  • *
  • Posts: 16
Scintilla Pascal
« Reply #3 on: June 10, 2005, 06:38:21 pm »
Did you checked what is at SciLexer.pas:3257  ???

Legolas

  • Full Member
  • ***
  • Posts: 117
    • http://itaprogaming.free.fr
Scintilla Pascal
« Reply #4 on: June 11, 2005, 02:21:07 pm »
Well, this is the incrimined code (at SciLexer.pas:3257):

Code: [Select]
function TScintilla.SPerform(Msg, wParam, lParam: Integer) : LongInt;
begin
  HandleNeeded;  // KV
  Result := SCPerform(sccmdctr, Msg, wParam, lParam);
end;


where:

Code: [Select]
SCPerform: TScintillaMessageFnc;


and:

Code: [Select]
TScintillaMessageFnc = function(ptr: Pointer; Msg, wParam, lParam: LongInt): LongInt; cdecl;


Now, setting a breakpoint to TScintilla.SPerform and stepping a bit,  I obtain:

Code: [Select]
Breakpoint 1, TSCINTILLA__SPERFORM (MSG=2030, WPARAM=0, LPARAM=0,
    this=$1fb42b8) at SciLexer.pas:3259
3259    SciLexer.pas: No such file or directory.
        in SciLexer.pas
(gdb) step
TWINCONTROL__HANDLENEEDED (this=$1fb42b8) at wincontrol.inc:3995
3995    wincontrol.inc: No such file or directory.
        in wincontrol.inc
(gdb) step
TWINCONTROL__HANDLEALLOCATED (this=$1fb42b8) at wincontrol.inc:3686
3686    in wincontrol.inc
(gdb) step
3687    in wincontrol.inc
(gdb) step
TWINCONTROL__HANDLENEEDED (this=$1fb42b8) at wincontrol.inc:4014
4014    in wincontrol.inc
(gdb) step
TSCINTILLA__SPERFORM (MSG=2030, WPARAM=0, LPARAM=0, this=$1fb42b8)
    at SciLexer.pas:3260
3260    SciLexer.pas: No such file or directory.
        in SciLexer.pas


What is "wincontrol.inc: No such file or directory"?!?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Scintilla Pascal
« Reply #5 on: June 13, 2005, 02:24:55 pm »
Quote from: "Legolas"
Well, this is the incrimined code (at SciLexer.pas:3257):

Code: [Select]
function TScintilla.SPerform(Msg, wParam, lParam: Integer) : LongInt;
begin
  HandleNeeded;  // KV
  Result := SCPerform(sccmdctr, Msg, wParam, lParam);
end;


where:

Code: [Select]
SCPerform: TScintillaMessageFnc;


Together with the AV @ 00000000 I think that the SCPerform variable is not initialized.

Quote

and:

Code: [Select]
TScintillaMessageFnc = function(ptr: Pointer; Msg, wParam, lParam: LongInt): LongInt; cdecl;


Where and how is this function assigned to the SCPerform variable ?

Quote

Now, setting a breakpoint to TScintilla.SPerform and stepping a bit,  I obtain:

Code: [Select]
Breakpoint 1, TSCINTILLA__SPERFORM (MSG=2030, WPARAM=0, LPARAM=0,
    this=$1fb42b8) at SciLexer.pas:3259
3259    SciLexer.pas: No such file or directory.
        in SciLexer.pas
(gdb) step
TWINCONTROL__HANDLENEEDED (this=$1fb42b8) at wincontrol.inc:3995
3995    wincontrol.inc: No such file or directory.
        in wincontrol.inc
(gdb) step
TWINCONTROL__HANDLEALLOCATED (this=$1fb42b8) at wincontrol.inc:3686
3686    in wincontrol.inc
(gdb) step
3687    in wincontrol.inc
(gdb) step
TWINCONTROL__HANDLENEEDED (this=$1fb42b8) at wincontrol.inc:4014
4014    in wincontrol.inc
(gdb) step
TSCINTILLA__SPERFORM (MSG=2030, WPARAM=0, LPARAM=0, this=$1fb42b8)
    at SciLexer.pas:3260
3260    SciLexer.pas: No such file or directory.
        in SciLexer.pas


What is "wincontrol.inc: No such file or directory"?!?

Detecting the right .inc file is a bit tricky. So when the ide/debugger cannot find/guess the correct .inc file it will ask you.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Legolas

  • Full Member
  • ***
  • Posts: 117
    • http://itaprogaming.free.fr
Scintilla Pascal
« Reply #6 on: June 14, 2005, 02:28:30 pm »
Quote from: "Marc"
Where and how is this function assigned to the SCPerform variable ?


SCPerform is set here:

Code: [Select]

procedure TScintilla.CreateWnd;
begin
  FCreating := True;
  try
    inherited CreateWnd;
  finally
    FCreating := False;
  end;
    {$IFNDEF FPC}
    @SCPerform := Pointer( SendMessage(WindowHandle, SCI_GETDIRECTFUNCTION,0,0) );
    sccmdctr := Pointer( SendMessage(WindowHandle, SCI_GETDIRECTPOINTER,0,0) );
    {$ELSE}
    SCPerform := TScintillaMessageFnc( SendMessage(Handle, SCI_GETDIRECTFUNCTION,0,0) );
    sccmdctr := Pointer( SendMessage(Handle, SCI_GETDIRECTPOINTER, 0, 0) );
    {$ENDIF FPC}

  if (ComponentState * [csLoading, csReading] = []) and assigned(FStateStream) then begin
    fStateStream.Position := 0;
    fStateStream.ReadComponent(Self);
    FreeAndNil(fStateStream);
    Perform(CM_FONTCHANGED, 0, 0);
  end;
end;


As you can see, I trapped a couple of lines in an IFDEF block, where I modified the code according with the "code conversion guide".

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Scintilla Pascal
« Reply #7 on: June 14, 2005, 04:37:57 pm »
What exactly is the result of the SendMessage function? Is it indeed a cdelc function?

Legolas

  • Full Member
  • ***
  • Posts: 117
    • http://itaprogaming.free.fr
Scintilla Pascal
« Reply #8 on: June 15, 2005, 12:59:25 pm »
Quote from: "Vincent"
What exactly is the result of the SendMessage function? Is it indeed a cdelc function?


Uhm... I don't know... I think it is a cdecl function because with Delphi it compiles fine.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Scintilla Pascal
« Reply #9 on: June 15, 2005, 01:58:40 pm »
cdecl and pascal is a bit strange.

BTW, why is a message used to get your own functionadress ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Legolas

  • Full Member
  • ***
  • Posts: 117
    • http://itaprogaming.free.fr
Scintilla Pascal
« Reply #10 on: June 15, 2005, 03:35:25 pm »
Quote from: "Marc"
cdecl and pascal is a bit strange.

BTW, why is a message used to get your own functionadress ?


I think because scintilla pascal is a wrapper built around a dll/so that is written in c. The wrapper needs to pass/get messages to/from that dll.

Anonymous

  • Guest
Scintilla Pascal
« Reply #11 on: May 13, 2006, 07:01:23 pm »
Quote from: "Legolas"
Quote from: "Marc"
Where and how is this function assigned to the SCPerform variable ?


SCPerform is set here:

Code: [Select]

procedure TScintilla.CreateWnd;
begin
  FCreating := True;
  try
    inherited CreateWnd;
  finally
    FCreating := False;
  end;
    {$IFNDEF FPC}
    @SCPerform := Pointer( SendMessage(WindowHandle, SCI_GETDIRECTFUNCTION,0,0) );
    sccmdctr := Pointer( SendMessage(WindowHandle, SCI_GETDIRECTPOINTER,0,0) );
    {$ELSE}
    SCPerform := TScintillaMessageFnc( SendMessage(Handle, SCI_GETDIRECTFUNCTION,0,0) );
    sccmdctr := Pointer( SendMessage(Handle, SCI_GETDIRECTPOINTER, 0, 0) );
    {$ENDIF FPC}

  if (ComponentState * [csLoading, csReading] = []) and assigned(FStateStream) then begin
    fStateStream.Position := 0;
    fStateStream.ReadComponent(Self);
    FreeAndNil(fStateStream);
    Perform(CM_FONTCHANGED, 0, 0);
  end;
end;


As you can see, I trapped a couple of lines in an IFDEF block, where I modified the code according with the "code conversion guide".

 

TinyPortal © 2005-2018