Discussion:
[Lazarus] How to debug DB errors.
Donald Ziesig via Lazarus
2018-05-30 14:24:30 UTC
Permalink
Hi Everyone,

I have been developing database apps for years and I have finally
reached my limit.  Occasionally I get exceptions in the db code but the
Call Stack is truncated as is shown below.  I usually just "bite the
bullet" and single step through the code till I find the offending
line.  This time, I got an exception after 8 hours of execution.  Is
there any way that I can set this up so that I get a location in my own
code?

The error message said there was a syntax error in the DBConnection
object caused by the letter 's'????

#0 fpc_raiseexception at :0
#1 SQLITE3CONN$_$TSQLITE3CONNECTION_$__$$_CHECKERROR$LONGINT at :0
#2 SQLITE3CONN$_$TSQLITE3CURSOR_$__$$_CHECKERROR$LONGINT at :0
#3 ?? at :0
#4 SQLITE3CONN$_$TSQLITE3CURSOR_$__$$_PREPARE$ANSISTRING$TPARAMS at :0
#5 .Ld24 at :0
#6 ?? at :0

Thanks,

Don Ziesig


--
Joost van der Sluis via Lazarus
2018-05-30 14:42:29 UTC
Permalink
Post by Donald Ziesig via Lazarus
I have been developing database apps for years and I have finally
reached my limit.  Occasionally I get exceptions in the db code but the
Call Stack is truncated as is shown below.  I usually just "bite the
bullet" and single step through the code till I find the offending
line.  This time, I got an exception after 8 hours of execution.  Is
there any way that I can set this up so that I get a location in my own
code?
You could try to install the LazDebuggerFP package, and switch to the
FPDebug debugger in your debugger-options. In a lot of cases it shows a
more complete callstack.

And did you already tried to use the fcl-db package with debug-info? If
you want to, go to a terminal, change to current directory to the fcl-db
source (where the fpmake.pp file is). Then do:

fppkg install -o -gl

Then build your application in Lazarus, and you will have fcl-db with
debug-info.

Regards,

Joost.



--
Donald Ziesig via Lazarus
2018-05-30 15:38:28 UTC
Permalink
Post by Joost van der Sluis via Lazarus
Post by Donald Ziesig via Lazarus
I have been developing database apps for years and I have finally
reached my limit.  Occasionally I get exceptions in the db code but
the Call Stack is truncated as is shown below.  I usually just "bite
the bullet" and single step through the code till I find the
offending line.  This time, I got an exception after 8 hours of
execution.  Is there any way that I can set this up so that I get a
location in my own code?
You could try to install the LazDebuggerFP package, and switch to the
FPDebug debugger in your debugger-options. In a lot of cases it shows
a more complete callstack.
And did you already tried to use the fcl-db package with debug-info?
If you want to, go to a terminal, change to current directory to the
fppkg install -o -gl
Then build your application in Lazarus, and you will have fcl-db with
debug-info.
Regards,
Joost.
Hi Joost!

Thanks for the quick response.

I found the fpmake.pp file in /usr/share/fpcsrc/3.0.4/packages/fcl-db. 
Using sudo -i, I ran:

fppkg install -o -gl

It responded "Error code 301", then "Compile successful".

I ran it again:

hp-laptop fcl-db # fppkg install -o -gl
Warning: Unexpected response status code: 301
The FPC Package tool encountered the following error:
Found broken packages, run "fppkg fixbroken" first

hp-laptop fcl-db # fppkg fixbroken
Warning: Unexpected response status code: 301
Re-install packages which are dependent on just installed packages
The FPC Package tool encountered the following error:
Stream read error

All google searches for error 301 showed "Moved permanently" as the
meaning.  Unfortunately, it doesn't show where it was looking when it
got the 301 error.  Any suggestions?

Don

--
Joost van der Sluis via Lazarus
2018-05-30 16:05:58 UTC
Permalink
Post by Donald Ziesig via Lazarus
I found the fpmake.pp file in /usr/share/fpcsrc/3.0.4/packages/fcl-db.
fppkg install -o -gl
It responded "Error code 301", then "Compile successful".
hp-laptop fcl-db # fppkg install -o -gl
Warning: Unexpected response status code: 301
Found broken packages, run "fppkg fixbroken" first
hp-laptop fcl-db # fppkg fixbroken
Warning: Unexpected response status code: 301
Re-install packages which are dependent on just installed packages
Stream read error
All google searches for error 301 showed "Moved permanently" as the
meaning.  Unfortunately, it doesn't show where it was looking when it
got the 301 error.  Any suggestions?
The URL to the central repository has changed from 'http' to 'https', so
that's why you see the redirect. But the main repository won't help you,
it is almost empty.

But in your case you can just ignore all this. Fppkg tries to recompile
all packages which are depending on fcl-db. But the only change is that
you added debug-info. So the recompile is not necessary.

Try to build your project, and see what happens.



(There is another repository you could try, search for your fppg.cfg
(run 'fppkg listsettings') and adapt the url to the central repository
to: http://fpc.cnoc.nl/repo/testing/mirrors.xml.

If you still miss any packages, ask me to add them.)

Regards,

Joost.
--
Donald Ziesig via Lazarus
2018-05-30 16:44:12 UTC
Permalink
Post by Joost van der Sluis via Lazarus
Post by Donald Ziesig via Lazarus
I found the fpmake.pp file in
fppkg install -o -gl
It responded "Error code 301", then "Compile successful".
hp-laptop fcl-db # fppkg install -o -gl
Warning: Unexpected response status code: 301
Found broken packages, run "fppkg fixbroken" first
hp-laptop fcl-db # fppkg fixbroken
Warning: Unexpected response status code: 301
Re-install packages which are dependent on just installed packages
Stream read error
All google searches for error 301 showed "Moved permanently" as the
meaning.  Unfortunately, it doesn't show where it was looking when it
got the 301 error.  Any suggestions?
The URL to the central repository has changed from 'http' to 'https',
so that's why you see the redirect. But the main repository won't help
you, it is almost empty.
But in your case you can just ignore all this. Fppkg tries to
recompile all packages which are depending on fcl-db. But the only
change is that you added debug-info. So the recompile is not necessary.
Try to build your project, and see what happens.
(There is another repository you could try, search for your fppg.cfg
(run 'fppkg listsettings') and adapt the url to the central repository
to: http://fpc.cnoc.nl/repo/testing/mirrors.xml.
If you still miss any packages, ask me to add them.)
Regards,
Joost.
Well, the IDE recompiles, but my app is having problems with my own
libraries that use *sqldb*.  The error message says that the checksum
has changed.  I tried recompiling all or the dependencies, but the error
does not change.

I am now going to uninstall Lazarus and FPC and re-installing it from
scratch.  Hopefully that will fix it.  If not, I'll let you know.

BTW, is there any log file that I might be missing that will get me
closer to the problem?

Don
Martin Schreiber via Lazarus
2018-05-30 17:57:04 UTC
Permalink
Post by Donald Ziesig via Lazarus
I am now going to uninstall Lazarus and FPC and re-installing it from
scratch. Hopefully that will fix it. If not, I'll let you know.
If the information in the stack window is insufficient in case of an exception
stop *all* used units including the Free Pascal RTL, FCL and the LCL should
be compiled with -gl -O-.

If you are on a 64 bit Windows FPC version and there still is no usable stack
trace compiling with 32 bit FPC may work better.

Martin
--
Joost van der Sluis via Lazarus
2018-05-30 20:52:09 UTC
Permalink
Post by Donald Ziesig via Lazarus
Post by Joost van der Sluis via Lazarus
Post by Donald Ziesig via Lazarus
I found the fpmake.pp file in
fppkg install -o -gl
It responded "Error code 301", then "Compile successful".
hp-laptop fcl-db # fppkg install -o -gl
Warning: Unexpected response status code: 301
Found broken packages, run "fppkg fixbroken" first
But in your case you can just ignore all this. Fppkg tries to
recompile all packages which are depending on fcl-db. But the only
change is that you added debug-info. So the recompile is not necessary.
Try to build your project, and see what happens.
Well, the IDE recompiles, but my app is having problems with my own
libraries that use *sqldb*.  The error message says that the checksum
has changed.  I tried recompiling all or the dependencies, but the error
does not change.
The compiler will tell you which .ppu's it uses. And it can not find the
proper sources to recompile the .ppu. Best is just to remove the .ppu
the compiler complains about, and try again. That way you know which
sources you are missing and add those (or their path, or compile them
and place the .ppu's in the path)
Post by Donald Ziesig via Lazarus
I am now going to uninstall Lazarus and FPC and re-installing it from
scratch.  Hopefully that will fix it.  If not, I'll let you know.
I doubt that this will help. If you want to get rid of all (local) fppkg
changes, you can just remove the ~/.fppkg directory.

Same holds for Lazarus and ~/.lazarus
Post by Donald Ziesig via Lazarus
BTW, is there any log file that I might be missing that will get me
closer to the problem?
The compiler log is you friend, I would say. (You could add the -va
compiler option in Lazarus, but this will give you way too much information)
Same holds for fppkg, add '-v' or '-d' and you will get more info.

Btw: Martin's suggestion to add -O- also is also a good suggestion. So:

fppkg -o -gl -o -O-

Regards,

Joost.
--

Martin Schreiber via Lazarus
2018-05-30 14:46:52 UTC
Permalink
Post by Donald Ziesig via Lazarus
Hi Everyone,
I have been developing database apps for years and I have finally
reached my limit.  Occasionally I get exceptions in the db code but the
Call Stack is truncated as is shown below.  I usually just "bite the
bullet" and single step through the code till I find the offending
line.  This time, I got an exception after 8 hours of execution.  Is
there any way that I can set this up so that I get a location in my own
code?
Run the application in the IDE and activate the 'Stop on exception' option in
IDE. I don't know how it is named in Lazarus, in MSEide it
is 'Project'-'Options'-'Debugger'-'Stop on Excep.'.

Martin
--
Mattias Gaertner via Lazarus
2018-05-30 14:54:53 UTC
Permalink
On Wed, 30 May 2018 16:46:52 +0200
Post by Martin Schreiber via Lazarus
[...]
Run the application in the IDE and activate the 'Stop on exception' option in
IDE.
This is default.

Mattias


--
Continue reading on narkive:
Loading...