|userdata types and detail formatter [message #1060747]
||Tue, 28 May 2013 06:45
| Marc Haderach
Registered: May 2013
I am using LDT 0.9 and I have been searching for a way to create bespoke detail formatters for my userdata types. |
I use Lua embedded in a C++ program and for performance reasons, my userdata are dictionaries that are passed around as pointers.
The default for LDT is to display a simple string "userdata: xxxx".
I created Lua functions that can convert my userdata into Lua tables, and if I type in the expressions window "my_converter(my_user_data)" I can see my userdata object properly as a table.
Is it possible to create a detail formatter that would by default call the my_converter function?
Thanks a lot.
|Re: userdata types and detail formatter [message #1060876 is a reply to message #1060747]
||Tue, 28 May 2013 15:28
| Julien Desgats
Registered: August 2012
To be more precise about the above link, I massively refactored introspection part of the debugger to allow custom inspectors which cover exactly your needs.|
Sadly, it is not yet documented: I started a tutorial but it is still WIP
If all your userdatas share the same metatable and you don't want to modify values from debugger implement it would be quite easy.
First you need the new debugger.lua file, and then plug a simple inspector should look like (untested):
-- regular debugger bootstrap
-- add your inspector
local introspection = require "debugger.introspection"
introspection.inspectors[my_metatable] = function(name, value, parent, fullname)
-- just inspect your customized table instead of userdata
return introspection.inspect(name, my_converter(value), parent, fullname)
Look debugger source for details, or this plugin for LuaJIT cdata for an actual example.
Again, this is still WIP so please report any problem you may encounter.
About value modification from debugger, this is a problem that has not been fully addressed yet. Currently the debugger will set value with something like value["key"] = loadstring(new_value)(), so unless this is possible with your userdata objects, it will fail.
[Updated on: Tue, 28 May 2013 15:30]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01709 seconds