2
DebugStack = DebugInstrument:extend
7
onNew = function (self)
8
self.title.text = 'Stack'
9
self.text = self:add(Text:new{ font = self.font, wordWrap = false })
10
self.lineHeight = self.text._fontObj:getHeight()
12
debugger.showStack = function (level) self:showStack(level) end
13
debugger.hideStack = function() self.visible = false end
17
-- Makes the instrument visible and shows a stack trace.
18
-- To hide this, just set the instrument's visible property to false.
21
-- level - stack level to show
26
showStack = function (self, level)
29
self.contentHeight = self.spacing * 2
34
info = debug.getinfo(level, 'nlS')
37
self.contentHeight = self.contentHeight + self.lineHeight
39
if info.name and info.name ~= '' then
40
self.text.text = self.text.text .. info.name .. '()\n'
41
elseif not info.name then
42
self.text.text = self.text.text .. '(anonymous function)\n'
44
self.text.text = self.text.text .. '(tail call)\n'
47
if info.currentline ~= -1 then
48
self.text.text = self.text.text .. ' ' .. info.short_src ..
49
':' .. info.currentline .. '\n'
51
self.contentHeight = self.contentHeight + self.lineHeight
59
onResize = function (self, x, y, width, height)
60
self.text.x = x + self.spacing
61
self.text.y = y + self.spacing
62
self.text.width = width - self.spacing * 2
63
self.text.height = height - self.spacing * 2