Recent

Author Topic: Trying to debug... need help...  (Read 10777 times)

Anonymous

  • Guest
Trying to debug... need help...
« on: January 16, 2006, 03:02:39 am »
Hi,
I'm sorry to ask for help like that but since my program would hang from time to time and I couldn't find where and why, I used dbg. As a beginner, my code is surely full of mistakes but it's not easy to find them...
I followed the doc on the Wiki and ended up with a nice backtrace but I can't understand what it means ... I would really appreciate if someone could give me a hint...
Here's the backtrace :
Quote
Current language:  auto; currently pascal
(gdb) bt
#0  $00456e18 in RAISEGDBEXCEPTION (MSG=$5e2fd4) at LCLProc.pas:588
#1  $0041a4bb in TCUSTOMFORM__SETACTIVECONTROL (AWINCONTROL=$168d60,
    this=$11ab50) at customform.inc:1163
#2  $0041853f in TCUSTOMFORM__FOCUSCONTROL (WINCONTROL=$168d60, this=$11ab50)
    at customform.inc:139
#3  $00493fcc in TWINCONTROL__SETFOCUS (this=$168d60) at wincontrol.inc:2442
#4  $00431fc1 in TFORM1__SPINEDITQUESTIONNUMBERCHANGE (SENDER=$0, this=$11ab50)
    at Unit1.pas:427
#5  $00437618 in TFORM1__MENUITEMOPENCLICK (SENDER=$12c230, this=$11ab50)
    at Unit1.pas:849
#6  $0049bc26 in TCONTROL__CLICK (this=$12c230) at control.inc:1822
#7  $004a4581 in TCUSTOMSPEEDBUTTON__CLICK (this=$12c230) at speedbutton.inc:76
#8  $0049bafa in TCONTROL__WMLBUTTONUP (MESSAGE=
      {MSG = 514, KEYS = 0, XPOS = 21, YPOS = 17, POS = {X = 21, Y = 17}, DUMMY
= 1114133, RESULT = 0}, this=$12c230) at control.inc:1777
#9  $00409927 in TOBJECT__DISPATCH (MESSAGE=void, this=$12c230)
    at objpas.inc:431
#10 $0049b5ba in TCONTROL__WNDPROC (THEMESSAGE=
      {MSG = 514, WPARAM = 0, LPARAM = 1114133, RESULT = 0, WPARAMLO = 0, WPARAM
HI = 0, LPARAMLO = 21, LPARAMHI = 17, RESULTLO = 0, RESULTHI = 0},
    this=$12c230) at control.inc:1499
#11 $0049a658 in TCONTROL__PERFORM (MSG=514, WPARAM=0, LPARAM=1114133,
    this=$12c230) at control.inc:990
#12 $00492b8c in TWINCONTROL__ISCONTROLMOUSEMSG (THEMESSAGE=
      {MSG = 514, KEYS = 0, XPOS = 53, YPOS = 17, POS = {X = 53, Y = 17}, DUMMY
= 1114165, RESULT = 0}, this=$11ab50) at wincontrol.inc:1781
#13 $00493bc9 in TWINCONTROL__WNDPROC (MESSAGE=
      {MSG = 514, WPARAM = 0, LPARAM = 1114165, RESULT = 0, WPARAMLO = 0, WPARAM
HI = 0, LPARAMLO = 53, LPARAMHI = 17, RESULTLO = 0, RESULTHI = 0},
    this=$11ab50) at wincontrol.inc:2289
#14 $00419b39 in TCUSTOMFORM__WNDPROC (THEMESSAGE=
      {MSG = 514, WPARAM = 0, LPARAM = 1114165, RESULT = 0, WPARAMLO = 0, WPARAM
HI = 0, LPARAMLO = 53, LPARAMHI = 17, RESULTLO = 0, RESULTHI = 0},
    this=$11ab50) at customform.inc:903
#15 $005159af in DELIVERMESSAGE (TARGET=$11ab50, MESSAGE=
      {MSG = 514, WPARAM = 0, LPARAM = 1114165, RESULT = 0, WPARAMLO = 0, WPARAM
HI = 0, LPARAMLO = 53, LPARAMHI = 17, RESULTLO = 0, RESULTHI = 0})
    at Win32Proc.pp:562
#16 $0046e8fe in WINDOWPROC (WINDOW=459668, MSG=514, WPARAM=0, LPARAM=1114165)
    at win32callback.inc:1522
#17 $77d18734 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
#18 $00070394 in ?? ()
#19 $00000202 in ?? ()
(gdb) quit
error return ../../gdb-6.0/gdb/win32-nat.c:1990 was 5

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Trying to debug... need help...
« Reply #1 on: January 16, 2006, 03:19:18 am »
We also needs some source code.

Can you give us what is the source of TFORM.SPINEDITQUESTIONNUMBERCHANGE ?

Also, take a look at TCustomForm.SetActiveControl. It seems you are trying to focus a control, and the LCL thinks it should disallow you to do that.

Anonymous

  • Guest
Trying to debug... need help...
« Reply #2 on: January 16, 2006, 03:55:31 am »
hi,
thanks for your quick reply... SpinEdit is used to load data from a stringgrid or to move to the next line of data (don't know if it helps).
The app creates some kind of quizzes.
Where can I find the procedure SetActiveControl? I have nothing such in the code... The only thing close might be :
with PageControl1 do ActivePage := Tabparameters;


Here's the spinedit code
Quote

procedure TForm1.SpinEditQuestionNumberChange(Sender: TObject);

begin
     EditQuestionText.text:= StringGridData.Cells[0,SpinEditQuestionNumber.value-1];
     EditAnswerA.text:=StringGridData.Cells[1,SpinEditQuestionNumber.value-1];
     EditAnswerB.text:=StringGridData.Cells[2,SpinEditQuestionNumber.value-1];
     EditAnswerC.text:=StringGridData.Cells[3,SpinEditQuestionNumber.value-1];
     EditAnswerD.text:=StringGridData.Cells[4,SpinEditQuestionNumber.value-1];
     EditFeedback.text:=StringGridData.Cells[6,SpinEditQuestionNumber.value-1];

     if StringGridData.Cells[5,SpinEditQuestionNumber.value-1]='' then
     begin
      StringGridData.Cells[5,SpinEditQuestionNumber.value-1]:='a';
      RadioButtonAnswerA.Checked:=True;
      end
     else if StringGridData.Cells[5,SpinEditQuestionNumber.value-1]='a'      then RadioButtonAnswerA.Checked:=True
     else if StringGridData.Cells[5,SpinEditQuestionNumber.value-1]='b' then RadioButtonAnswerB.Checked:=True
     else if StringGridData.Cells[5,SpinEditQuestionNumber.value-1]='c' then RadioButtonAnswerC.Checked:=True
     else if StringGridData.Cells[5,SpinEditQuestionNumber.value-1]='d' then RadioButtonAnswerD.Checked:=True;
     EditQuestionText.Setfocus;

     
end;

Thanks a lot for your help...

Anonymous

  • Guest
Trying to debug... need help...
« Reply #3 on: January 16, 2006, 04:17:06 am »
According to what you said, I removed the EditQuestionText.Setfocus and it seems to work ok.
What should I have written to give this edit the focus?

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Trying to debug... need help...
« Reply #4 on: January 16, 2006, 07:24:01 am »
Maybe, before setting the focus, make it visible:

EditQuestionText.Visible := true;

Anonymous

  • Guest
Trying to debug... need help...
« Reply #5 on: January 16, 2006, 06:01:14 pm »
The "funny" part (funny is not the word since I spent hours looking for the bug) is that the code runs perfectly on linux. I also tried to use gdb to see and the same code does not produce any error.
Anyway, dank u wel for your help since I would never have thought It would come from there.
To understand gdb backtrace, do you just look at any line or is a way to isolate the faulty segment?
Thanks a lot again...

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Trying to debug... need help...
« Reply #6 on: January 16, 2006, 07:02:51 pm »
Looking from the top, you look at the line that raises the exception and then try to find out why that happened.

Further down, I looked at the mention of user code, to figure out what why this code was called.

If I want to find something in the LCL, I always use Search -> Find in files, with a directory search. As directory I specify, c:\lazarus\lcl (or whereever you decided to put Lazarus).

 

TinyPortal © 2005-2018