2
-- This shows a stack trace for a particular stack level.
4
DebugStack = DebugInstrument:extend
9
onNew = function (self)
10
self.title.text = 'Stack'
11
self.text = self:add(Text:new{ font = self.font, wordWrap = false })
12
self.lineHeight = self.text._fontObj:getHeight()
14
debugger.showStack = function (level) self:showStack(level) end
15
debugger.hideStack = function() self.visible = false end
19
-- Makes the instrument visible and shows a stack trace.
20
-- To hide this, just set the instrument's visible property to false.
23
-- level - stack level to show
28
showStack = function (self, level)
31
self.contentHeight = self.spacing * 2
36
info = debug.getinfo(level, 'nlS')
39
self.contentHeight = self.contentHeight + self.lineHeight
41
if info.name and info.name ~= '' then
42
self.text.text = self.text.text .. info.name .. '()\n'
43
elseif not info.name then
44
self.text.text = self.text.text .. '(anonymous function)\n'
46
self.text.text = self.text.text .. '(tail call)\n'
49
if info.currentline ~= -1 then
50
self.text.text = self.text.text .. ' ' .. info.short_src ..
51
':' .. info.currentline .. '\n'
53
self.contentHeight = self.contentHeight + self.lineHeight
61
onResize = function (self, x, y, width, height)
62
self.text.x = x + self.spacing
63
self.text.y = y + self.spacing
64
self.text.width = width - self.spacing * 2
65
self.text.height = height - self.spacing * 2