Recent

Author Topic: How to reset gdb settings  (Read 22647 times)

jagorath

  • New Member
  • *
  • Posts: 34
How to reset gdb settings
« on: August 26, 2010, 02:17:50 am »
I seem to have completely hosed my debugger settings within Lazarus somehow, is there a way to clear the settings so they will be restored to the default?  Perhaps by deleting an .ini file?

Currently I have to run without a debugger specified because if I specify one the application doesn't run.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7434
  • Debugger - SynEdit - and more
    • wiki
Re: How to reset gdb settings
« Reply #1 on: August 26, 2010, 02:31:43 am »
There aren't many debugger related settings, and I am not sure, if the default will be of much use (since you need to specify at least the location of gdb.exe)

Lazarus settings are in the user folder
/home/name/.lazarus/*
C:\Users\name\AppData\Local\lazarus\*

Make a backup

Other setting are in your
project.lpi
project.lps

lps is optional, and may either be in project dir, or the above user dir
C:\Users\name\AppData\Local\lazarus\projectsessions

-----------
Better is to just set debugger type = gdb
and select a gdb.exe (should be in a subfolder of your lazarus dir)

in the project options, make sure you compile with debug info
-g
or
-gw

And make sure:
- you do not strip debug info
- you do not use an external debug info file

jagorath

  • New Member
  • *
  • Posts: 34
Re: How to reset gdb settings
« Reply #2 on: August 26, 2010, 04:51:56 am »
Thanks for the reply Martin_fr, I set the debugger to C:\lazarus\mingw\bin\gdb.exe and the type GDB, and made sure -g was included in the options.  The problem remains though - when I run the app it doesn't show up, like gdb can't attach to it or something, and I have to stop the app.

I'm using 64-bit lazarus, perhaps GDB only works with 32-bit?
« Last Edit: August 26, 2010, 07:02:57 am by jagorath »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7434
  • Debugger - SynEdit - and more
    • wiki
Re: How to reset gdb settings
« Reply #3 on: August 26, 2010, 10:43:05 am »
gdb should work on 64 bit.

not sure,on 64 bit, you may need dwarf -gw

You may check on the mingw website if there is a 64bit release.
You can also download an updated gdb from there

One other thing. There seem several anti-virus-solutions, that don't like gdb: Commodo, Bitdefender, others...


In Lazarus "View menu" is a sub menu "debug windows" with an entry "debug output".
Have a look what it says, and you may upload it here.

jagorath

  • New Member
  • *
  • Posts: 34
Re: How to reset gdb settings
« Reply #4 on: August 30, 2010, 09:38:59 pm »
Nice, I didn't know about that Debug Output window.  I enabled Dwarf, and this is what it returned in the debug window.  Seems it can't insert breakpoints, even though I didn't define any.  It seems it doesn't recognize the exe format somehow.

I also investigated 64-bit mingw and AFAICT there is only one version of it, and it supports both 32 and 64-bits.

<-file-exec-and-symbols "C:/Users/Alan/Documents/MarketPoint/Exe/MBAnalyzer/MBAnalyzer64.exe">
^done
(gdb)
<-gdb-set language pascal>
^done
(gdb)
<-environment-cd .>
^done
(gdb)
<-environment-cd "C:/Users/Alan/Documents/MarketPoint/Exe/MBAnalyzer/">
^done
(gdb)
<-data-evaluate-expression FPC_THREADVAR_RELOCATE_PROC>
&"No symbol \"FPC_THREADVAR_RELOCATE_PROC\" in current context.\n"
^error,msg="No symbol \"FPC_THREADVAR_RELOCATE_PROC\" in current context."
(gdb)
<info functions FPC_CPUINIT>
&"info functions FPC_CPUINIT\n"
~"All functions matching regular expression \"FPC_CPUINIT\":\n"
~"\n"
~"Non-debugging symbols:\n"
~"0x0000000000002f50  SYSTEM_FPC_CPUINIT\n"
^done
(gdb)
<-exec-arguments >
^done
(gdb)
<set width 50000>
&"set width 50000\n"
^done
(gdb)
<-gdb-set language pascal>
^done
(gdb)
<info address main>
&"info address main\n"
&"invalid dwarf2 offset 6443956\n"
^error,msg="invalid dwarf2 offset 6443956"
(gdb)
<-break-insert -t main>
&"invalid dwarf2 offset 6443956\n"
^done
(gdb)
<ptype TObject>
&"ptype TObject\n"
&"invalid dwarf2 offset 8449350\n"
^error,msg="invalid dwarf2 offset 8449350"
(gdb)
<info address FPC_RAISEEXCEPTION>
&"info address FPC_RAISEEXCEPTION\n"
~"Symbol \"FPC_RAISEEXCEPTION\" is at 0xe050 in a file compiled without debugging.\n"
^done
(gdb)
<-break-insert *57424>
^done,bkpt={number="6",type="breakpoint",disp="keep",enabled="y",addr="0x000000000000e050",at="",times="0"}
(gdb)
<info address FPC_BREAK_ERROR>
&"info address FPC_BREAK_ERROR\n"
~"Symbol \"FPC_BREAK_ERROR\" is at 0x104a0 in a file compiled without debugging.\n"
^done
(gdb)
<-break-insert *66720>
^done,bkpt={number="7",type="breakpoint",disp="keep",enabled="y",addr="0x00000000000104a0",at="",times="0"}
(gdb)
<info address FPC_RUNERROR>
&"info address FPC_RUNERROR\n"
~"Symbol \"FPC_RUNERROR\" is at 0x105d0 in a file compiled without debugging.\n"
^done
(gdb)
<-break-insert *67024>
^done,bkpt={number="8",type="breakpoint",disp="keep",enabled="y",addr="0x00000000000105d0",at="",times="0"}
(gdb)
<info file>
&"info file\n"
~"Symbols from \"C:/Users/Alan/Documents/MarketPoint/Exe/MBAnalyzer/MBAnalyzer64.exe\".\n"
~"Local exec file:\n"
~"\t`C:/Users/Alan/Documents/MarketPoint/Exe/MBAnalyzer/MBAnalyzer64.exe', file type pei-x86-64.\n"
~"\tEntry point: 0x100015e80\n"
~"\t0x0000000100001000 - 0x00000001003d7100 is .text\n"
~"\t0x00000001003d8000 - 0x000000010052e800 is .data\n"
~"\t0x000000010052f000 - 0x0000000100537490 is .bss\n"
~"\t0x0000000100538000 - 0x000000010053bd54 is .idata\n"
~"\t0x000000010053c000 - 0x00000001005a8be8 is .rsrc\n"
^done
(gdb)
<-break-insert -f foo>
&"Function \"foo\" not defined.\n"
^done,bkpt={number="9",type="breakpoint",disp="keep",enabled="y(p)",addr="<PENDING>",pending="foo",times="0"}
(gdb)
<-break-delete 9>
^done
(gdb)
<-exec-run>
^running
(gdb)
&"Warning:\n"
&"Cannot insert breakpoint 1.\n"
&"Error accessing memory address 0x2c20: Input/output error.\n"
&"Cannot insert breakpoint 6.\n"
&"Error accessing memory address 0xe050: Input/output error.\n"
&"\n"
^error,msg="Warning:\nCannot insert breakpoint 1.\nError accessing memory address 0x2c20: Input/output error.\nCannot insert breakpoint 6.\nError accessing memory address 0xe050: Input/output error.\n"
(gdb)
<info program>
&"info program\n"
~"\tUsing the running image of child thread 420.0xd4c.\n"
~"Program stopped at 0x0.\n"
~"Type \"info stack\" or \"info registers\" for more information.\n"
^done
(gdb)
<-exec-continue>
^running
(gdb)
&"Warning:\n"
&"Cannot insert breakpoint 1.\n"
&"Error accessing memory address 0x2c20: Input/output error.\n"
&"Cannot insert breakpoint 6.\n"
&"Error accessing memory address 0xe050: Input/output error.\n"
&"\n"
^error,msg="Warning:\nCannot insert breakpoint 1.\nError accessing memory address 0x2c20: Input/output error.\nCannot insert breakpoint 6.\nError accessing memory address 0xe050: Input/output error.\n"
(gdb)

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2530
Re: How to reset gdb settings
« Reply #5 on: September 01, 2010, 04:33:53 pm »
Lazarus itself needs some breakpoints to be able to catch exceptions.

But the lines

&"info address main\n"
&"invalid dwarf2 offset 6443956\n"
...
~"Symbol \"FPC_RAISEEXCEPTION\" is at 0xe050 in a file compiled without debugging.\n"

indicate that there is something wrong with the debug info. 0xe050 is a pretty low address. It is unlikely that it contains valid code.

compile with -WB00400000

For more info see http://bugs.freepascal.org/view.php?id=15692
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

jagorath

  • New Member
  • *
  • Posts: 34
Re: How to reset gdb settings
« Reply #6 on: September 01, 2010, 11:02:25 pm »
Thank-you Marc, that did it!  Using -WB00400000 and a new gdb from http://svn2.freepascal.org/svn/lazarus/binaries/x86_64-win64/gdb/bin/ , I was able to get it working.  Nice one.

anonim

  • New Member
  • *
  • Posts: 13
Re: How to reset gdb settings
« Reply #7 on: May 16, 2013, 09:49:34 am »
I am using Lazarus 1.0.8 on Windows XP.
The execution stops at the breapoint, however I get an error "cannot insert a breakpoint" when trying to step over or step into.
In another project the breapoints work normally. I have checked project setting for both projects and cannot see any differences. The project in question some time ago used to be debuggable and then suddenly debugging does not work anymore.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7434
  • Debugger - SynEdit - and more
    • wiki
Re: How to reset gdb settings
« Reply #8 on: May 16, 2013, 11:04:03 am »
I am using Lazarus 1.0.8 on Windows XP.
The execution stops at the breapoint, however I get an error "cannot insert a breakpoint" when trying to step over or step into.
In another project the breapoints work normally. I have checked project setting for both projects and cannot see any differences. The project in question some time ago used to be debuggable and then suddenly debugging does not work anymore.

32 or 64 bit?

Using the GDB that comes with Lazarus, or updated GDB yourself?

Any spaces in the file/project-name?

Check and compare the project related setup options: http://wiki.lazarus.freepascal.org/Debugger_Setup
- No smart linking
- Optimization: none or -O1

"Reset the debugger" (run menu) before starting

-----------
If none helps: logfile please: http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session

anonim

  • New Member
  • *
  • Posts: 13
Re: How to reset gdb settings
« Reply #9 on: May 17, 2013, 08:44:53 am »
I am using Lazarus 1.0.8 on Windows XP.
The execution stops at the breapoint, however I get an error "cannot insert a breakpoint" when trying to step over or step into.
In another project the breapoints work normally. I have checked project setting for both projects and cannot see any differences. The project in question some time ago used to be debuggable and then suddenly debugging does not work anymore.

32 or 64 bit?

Using the GDB that comes with Lazarus, or updated GDB yourself?

Any spaces in the file/project-name?

Check and compare the project related setup options: http://wiki.lazarus.freepascal.org/Debugger_Setup
- No smart linking
- Optimization: none or -O1

"Reset the debugger" (run menu) before starting

-----------
If none helps: logfile please: http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session
standard Lazarus 1.0.8 32 bit on 32 bit Windows XP Pro.
Debugger settings are as you recommended. I tried to set debug info to Dwarf. The result is the same - execution stops at the breakpoint and step over/step into generates the following error:
Quote
,msg="Warning:\nCannot insert breakpoint -102.\nError accessing memory address 0x78ab0050: Input/output error.\n"

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7434
  • Debugger - SynEdit - and more
    • wiki
Re: How to reset gdb settings
« Reply #10 on: May 17, 2013, 01:15:10 pm »
Quote
,msg="Warning:\nCannot insert breakpoint -102.\nError accessing memory address 0x78ab0050: Input/output error.\n"

Ah, there is an important bit. negative number.

Background:
When you step the application, gdb inserts temporary breakpoints. GDB calculates the different  paths the code  can take, and on each location where it could  (in the opinion of GDB) reach the end of the current statement, GDB will set a temp breakpoint.

Such temp breakpoints always have negative numbers. While breakpoints set by you have positive numbers.

Sometimes GDB gets it wrong. Usually when window add threads in the background.
The address 0x78ab0050 indicates that temp the breakpoint GDB attempts to set, is not in your code. It is in a system (or driver) dll or even in the kernel. The OS prevents GDB from setting breakpoints there.

---------
Most often, I have seen this after a file-open/save dialog was executed (right after the OK click, when opendialeg.execute returns). When a File dialog is displayed windows starts a lot of threads.
But it may happen with other DLL, or with custom drivers for hardware on your system....


I have not yet found a reliable way to prevent this error.

The good thing is, hat your debug session is still alive. You can confirm the error, and return to the paused application.

Also, once the OS cleaned up the threads, it will all work again. Unfortunately this only happens, if you run the app.
(You can watch in the thread window / It may take a while to do so)

To get past this, you will have to:
- set breakpoints (F5) on the next line, and use F9 to run to the next breakpoint. (recommended)
- or use the assembler window, and single step asm instructions (but that is more work)
- I have NOT tested / this may NOT work:  you can try to use F4 (step to cursor). This means you need to place the cursor on the line, on which you want to stop next (and this line MUST be in the current procedure)

anonim

  • New Member
  • *
  • Posts: 13
Re: How to reset gdb settings
« Reply #11 on: May 17, 2013, 03:05:57 pm »
Quote
,msg="Warning:\nCannot insert breakpoint -102.\nError accessing memory address 0x78ab0050: Input/output error.\n"

Ah, there is an important bit. negative number.
Most often, I have seen this after a file-open/save dialog was executed (right after the OK click, when opendialeg.execute returns). When a File dialog is displayed windows starts a lot of threads.
But it may happen with other DLL, or with custom drivers for hardware on your system....
To get past this, you will have to:
- set breakpoints (F5) on the next line, and use F9 to run to the next breakpoint. (recommended)
- or use the assembler window, and single step asm instructions (but that is more work)
- I have NOT tested / this may NOT work:  you can try to use F4 (step to cursor). This means you need to place the cursor on the line, on which you want to stop next (and this line MUST be in the current procedure)
You are right, I am using a few calls to TOpenDialog.Execute and TSaveDialog.Execute before running the procedure.
Setting a new breakpoint  below the first one did not help. First click on Step over/Step into button does nothing, the second click produces an error message with negative error number.
step to cursor did not work either.
Another very similar project where I have no problems with breakpoint differs in that the second project uses TFileNameEdit components instead of TOpenDialog and TSaveDialog.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7434
  • Debugger - SynEdit - and more
    • wiki
Re: How to reset gdb settings
« Reply #12 on: May 17, 2013, 03:24:00 pm »
You are right, I am using a few calls to TOpenDialog.Execute and TSaveDialog.Execute before running the procedure.
Setting a new breakpoint  below the first one did not help. First click on Step over/Step into button does nothing, the second click produces an error message with negative error number.
step to cursor did not work either.
Another very similar project where I have no problems with breakpoint differs in that the second project uses TFileNameEdit components instead of TOpenDialog and TSaveDialog.

Setting a normal breakpoint (and then using F9, normal run, instead of F8) should have worked. Strange.

In this case, can you please send a log: http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session

----
While I know it is very inconvenient,  it is a GDB problem, and the IDE will not be able to fix it.
So all it is, is to look far the most convenient workaround.

You might also want to try this:
- Once you hit the breakpoint (after opendialog.execute), do NOT press F8 at all
- open the "thread" window, from the Menu View > debug windows.
- While there are multiple threads, do not use F8, but use the breakpoint + F9

I know, it is a crap way of debugging, but it hopefully will not be to often...


 

TinyPortal © 2005-2018