-
Hello! I have been working with the Lua API quite a bit, and there are a few things that seemingly don't work as I might expect them to, symbol tables being the latest among them. I assumed that symbol tables would allow access to the debugger's symbol tables (and, rather excitingly, allow for adding symbols to the debugger's tables) for use in debugger expressions, but this does not seem the case, which leaves me to wonder: what is the point of symbol tables? Expectation was something like this allowing me to print a stack trace from Lua land on breakpoint (in a m68k architecture machine, namely CPS2): local syms = emu.symbol_table(manager.machine.devices[':maincpu'])
local m = manager.machine.devices[':maincpu'].spaces['program']
syms:add(
'print_stack_trace',
1,
1,
function(usp)
local current_address = usp
local stack_value = m:read_u32(usp)
while stack_value ~= 0 do
print(string.format('%08x', stack_value))
current_address = current_address + 8
stack_value = m:read_u32(current_address)
end
end
)
local expr = emu.parsed_expression(syms, 'print_stack_trace(usp)')
emu.add_machine_stop_notifier(function()
expr:execute()
end) Firstly, Still, I thought maybe I'd be able to do something like this in the debugger: Now, you can print a stack trace using symbols; that's certainly achievable. But you end up doing all of the things you'd be able to do without symbol tables anyway: local cpu = manager.machine.devices[':maincpu']
local m = cpu.spaces['program']
syms:add(
'usp',
function()
return cpu.state['USP'].value
end,
function(addr)
cpu.state['USP'].value = addr
end,
'%08x')
syms:add('print_stack_trace', 1, 1, function(usp)
local current_address = usp
local stack_value = m:read_u32(current_address)
while stack_value ~= 0 do
print(string.format('%08x', stack_value))
current_address = current_address + 8
stack_value = m:read_u32(current_address)
end
end)
emu.parsed_expression(syms, 'print_stack_trace(usp)'):execute() This all leaves me scratching my head and wondering: what is the point of symbol tables? The only use case I can think of is easily sharing functions and data between plugins, but beyond that, I'm not smart enough to come up with anything. What is their "intended" use? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Lua plugins need to be able to manipulate symbol tables in order for me to be able create a proper replacement for the built-in cheat engine. The current hacky approach of trying to lexically convert debugger expressions to Lua expressions is flaky and doesn’t always work properly. More generally, symbol tables can be by plugins or scripts that accept user input using debugger expression syntax to trigger on arbitrary events. Your observation that they don’t allow scripts to inject symbols into the debugger is correct. That may change in the future.
|
Beta Was this translation helpful? Give feedback.
Lua plugins need to be able to manipulate symbol tables in order for me to be able create a proper replacement for the built-in cheat engine. The current hacky approach of trying to lexically convert debugger expressions to Lua expressions is flaky and doesn’t always work properly. More generally, symbol tables can be by plugins or scripts that accept user input using debugger expression syntax to trigger on arbitrary events.
Your observation that they don’t allow scripts to inject symbols into the debugger is correct. That may change in the future.
emu.add_machine_stop_notifier()
adds a notifier th…