Recent

Author Topic: How do you use the debugger - gdb  (Read 23955 times)

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
How do you use the debugger - gdb
« Reply #15 on: October 01, 2007, 11:09:49 am »
Do you get that exact error message from gdb ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Elphi

  • Full Member
  • ***
  • Posts: 132
How do you use the debugger - gdb
« Reply #16 on: October 01, 2007, 11:47:52 pm »
No, I don't "get" anything from gdb. When I start the program it should stop waiting for user input, but nothing happens. Note my question: how to use the debugger...
When I then stop "debugging" with Reset Debugger an AV happens. I then can press Ok risking data corruption or Cancel (to kill the program, i.e. Lazarus).
It smells like debugger problems doesn't it?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
How do you use the debugger - gdb
« Reply #17 on: October 02, 2007, 11:49:57 am »
Now you talk about a complete different thing. Whne working with lazarus, I don't expect apps waiting for userinput (on the console or didn't you mean that).

Stopping the debugger runs through a fixed number of steps which normally should give a certain response. When gdb is waiting for user input, it cannot give those responses and the gdb wrapper doesn't handle that well -> AV, which you can ignore.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Elphi

  • Full Member
  • ***
  • Posts: 132
How do you use the debugger - gdb
« Reply #18 on: October 03, 2007, 01:29:39 pm »
Yes I mean a console applcation which Lazarus calls a Program.
I certainly am talking about the same thing: debugging my program.

Its a rather complex multithreaded application server. When started the user can give commands at the prompt to (de)activate the server, or shut it down.

With Lazarus/win32 the program stops at all breakpoints declared. Also I get a terminal window.

With Lazarus/Linux-x86_64-gtk, with the same source files I have debugging problems.

One problem, location in source mismatch, is solved by running "Clean directory". In my opinion this shouldn't be necessary.

Another problem is that when I set the GNU debugger (in "Debugger Options") and run the program, I don't get the terminal window. When setting debugger to "[none]" a get the terminal window, as expected. It seems now that a problem with breakpoints in units that are skipped is related to the fact that the terminal windows doesn't appear. It looks like the programs hangs somewhere.
I've found that even from a simple program I don't get a terminal:
Code: [Select]

program Project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  Classes
  { add your units here };

var
  Command: Char;
  KeepListening: Boolean;
 
begin
  KeepListening := True;
  while KeepListening do
  begin
    write('>');
    readln(Command);
    case Command of
      'c': writeln('continue');
      'q': begin
             writeln ('quit');
             KeepListening := False;
           end;
    end;
  end;

end.    

Indeed, now I don't think anymore the problem arises from my lack of knowlegde of the GNU-debugger. I looks like a clear case for a bug report, doesn't it?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
How do you use the debugger - gdb
« Reply #19 on: October 04, 2007, 12:10:18 pm »
nope, debugging console apps with lazarus throug gdb is not supported.

The reason: to control gdb I need the console input/output of gdb. With gdb it is not possible to create a separate console for your application, so when the app stops, I don't know if it is the user program or it is gdb
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Elphi

  • Full Member
  • ***
  • Posts: 132
How do you use the debugger - gdb
« Reply #20 on: October 04, 2007, 06:52:12 pm »
In essence you are saying that console programs can't be debugged in any way. If I enable gbd I don't get any console, nor from gdb neither from my program. When I disable gdb I can't set breakpoints. That's bad news.

As an alternative I've created my server class in a formcreate event handler.    The breakpoints I've set in the source creating the server are ignored. When the form appears and I press a button to activate the server, execution stops in the event handler where no breakpoint is set. I conclude that the debugger  is aware of a previous breakpoint, but doesn't stop there. I'm sure the file compiled is the file with the breakpoints.

Elphi

  • Full Member
  • ***
  • Posts: 132
How do you use the debugger - gdb
« Reply #21 on: October 05, 2007, 12:33:02 am »
In addition to the previous post I went back to win32. Contrary to what you're saying on this platform with gdb set, I can debug the same console program with breakpoints recognized, and it gives me the console of my program for user input.

Please, can you clarify this?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
How do you use the debugger - gdb
« Reply #22 on: October 05, 2007, 10:36:50 am »
A linux console is not equal to a windows console. Besides that, gdb may implement things different on windows than on linux.

Quote

As an alternative I've created my server class in a formcreate event handler. The breakpoints I've set in the source creating the server are ignored.

I keep with one of my first postings, there is something wrong with your debuginfo. Either the wrong source, or the wrong unit, or something else. But you should be able to set a breakpoint.
Are you sure you didn't name the unit similar to some rtl/fcl unit ?
Do you have spaces in the path to any source file ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Elphi

  • Full Member
  • ***
  • Posts: 132
How do you use the debugger - gdb
« Reply #23 on: October 05, 2007, 11:26:20 pm »
Quote from: "Marc"
A linux console is not equal to a windows console. Besides that, gdb may implement things different on windows than on linux.

Could be, but Lazarus will hide these platform peculiarities for me?

Quote from: "Marc"
But you should be able to set a breakpoint.

I fully agree!

Quote from: "Marc"
Are you sure you didn't name the unit similar to some rtl/fcl unit ?
Do you have spaces in the path to any source file ?

mnt/y/y-invent/trunk/middleware/ymserver.pas

Obviously there's no simple answer. Hopefully next week I 'll dive into the matter again trying to pinpoint the problem better. Thanks anyways.

 

TinyPortal © 2005-2018