[Tile-serving] [openstreetmap/osm2pgsql] [demo] interactive debugging (Discussion #1796)
mmd
notifications at github.com
Mon Oct 17 20:10:26 UTC 2022
This is not a feature request or anything, I just wanted to share a few screenshots illustrating how Lua scripts can be debugged while running osm2pgsql. Debugging in this case means, integrating [this Lua debugger](https://github.com/slembcke/debugger.lua), and run flex processing as usual.
Whenever there's an error in the script, or the debugger is triggered explicitly, processing stops and you end up in debug mode.
You can require other Lua files from there, play around with osm2pgsql.* functions, or change any values while processing an object.
This might be interesting for people who struggle a bit with Lua, and want learn a bit more about the details in an interactive way.

generic.lua:
```lua
local dbg = require 'debugger'
[...]
function osm2pgsql.process_node(object)
if clean_tags(object.tags) then
return
end
if object.id == 500661 then
dbg()
end
```
```
<return> => re-run last command
c(ontinue) => continue execution
s(tep) => step forward by one line (into functions)
n(ext) => step forward by one line (skipping over functions)
f(inish) => step forward until exiting the current function
u(p) => move up the stack by one frame
d(own) => move down the stack by one frame
w(here) [line count] => print source code around the current line
e(val) [statement] => execute the statement
p(rint) [expression] => execute the expression and print the result
t(race) => print the stack trace
l(ocals) => print the function arguments, locals and upvalues.
h(elp) => print this message
q(uit) => halt execution
```
I have uploaded this strictly proof-of-concept demo here, if anyone wants to play with it: https://github.com/mmd-osm/osm2pgsql/tree/debugger
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/discussions/1796
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/osm2pgsql/repo-discussions/1796 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20221017/fd9f2ce3/attachment.htm>
More information about the Tile-serving
mailing list