Skip to content
Snippets Groups Projects
Commit 8c46b3fe authored by Timur Safin's avatar Timur Safin Committed by Igor Munkin
Browse files

debugger: introduce logging facility

It's frequently needed to see interaction of a luatest script
and its chield launched via popen.
Now we display extra debugging information received from
children pipes directly to the parent screen. It's hidden
by default by luatest (if everything goes well), but could
be displayed with `luatest -c` option.

```
luatest -c -v app-luatest/console_debugger_session_test.lua
```

NO_DOC=internal
NO_CHANGELOG=internal

(cherry picked from commit 7a813f43)
parent fc14740f
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,10 @@ local function dbg_failed_range(v) ...@@ -37,6 +37,10 @@ local function dbg_failed_range(v)
format(v, 1, 0x7fffff00) format(v, 1, 0x7fffff00)
end end
local function debuglog(...)
print('--', ...)
end
local cmd_aliases = { local cmd_aliases = {
['b'] = 'b|break|breakpoint|add_break|add_breakpoint', ['b'] = 'b|break|breakpoint|add_break|add_breakpoint',
['bd'] = 'bd|bdelete|delete_break|delete_breakpoint', ['bd'] = 'bd|bdelete|delete_break|delete_breakpoint',
...@@ -197,12 +201,14 @@ local function run_debug_session(cmdline, sequence, header) ...@@ -197,12 +201,14 @@ local function run_debug_session(cmdline, sequence, header)
cmd = cmd .. '\n' cmd = cmd .. '\n'
end end
fh:write(cmd) fh:write(cmd)
debuglog('Execute command: "'..trim(cmd)..'"')
end end
local result local result
local clean_cmd = trim(cmd) local clean_cmd = trim(cmd)
-- there should be empty stderr - check it before stdout -- there should be empty stderr - check it before stdout
local errout = fh:read({ timeout = 0.05, stderr = true}) local errout = fh:read({ timeout = 0.05, stderr = true})
debuglog('stderr output: ', trim(errout))
if first and errout then if first and errout then
-- we do not expect anything on stderr -- we do not expect anything on stderr
-- with exception of initial debugger header -- with exception of initial debugger header
...@@ -213,6 +219,7 @@ local function run_debug_session(cmdline, sequence, header) ...@@ -213,6 +219,7 @@ local function run_debug_session(cmdline, sequence, header)
end end
repeat repeat
result = trim(unescape(fh:read({ timeout = 0.5 }))) result = trim(unescape(fh:read({ timeout = 0.5 })))
debuglog('stdout output:', result)
until result ~= '' or result ~= clean_cmd until result ~= '' or result ~= clean_cmd
if expected ~= '' then if expected ~= '' then
t.assert_str_contains(result, expected, false) t.assert_str_contains(result, expected, false)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment