forked from LuaJIT/LuaJIT
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
profilers: print user-friendly errors
Prior to this patch, there was no error-checking in profilers, which resulted in raw Lua errors being reported in cases of non-existing paths or corrupt file structures. This patch adds error handling, so all parsing errors are now reported in a user-friendly manner. Event parsing is now moved into a separate profiler-agnostic module. Tool CLI flag tests are adapted correspondingly to error message changes. Resolves tarantool/tarantool#9217 Part of tarantool/tarantool#5994
- Loading branch information
1 parent
ac1f1f1
commit 40b4c39
Showing
7 changed files
with
57 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
local bufread = require('utils.bufread') | ||
local symtab = require('utils.symtab') | ||
|
||
local function make_xpcall_handler(inputfile, fmt) | ||
return function() | ||
io.stderr:write(string.format(fmt, inputfile)) | ||
os.exit(1, true) | ||
end | ||
end | ||
|
||
local function safe_event_reader(inputfile, parser) | ||
local _, reader = xpcall( | ||
bufread.new, | ||
make_xpcall_handler(inputfile, 'Failed to open %s.'), | ||
inputfile | ||
) | ||
|
||
local _, symbols = xpcall( | ||
symtab.parse, | ||
make_xpcall_handler(inputfile, 'Failed to parse symtab from %s.'), | ||
reader | ||
) | ||
|
||
local _, events = xpcall( | ||
parser, | ||
make_xpcall_handler(inputfile, 'Failed to parse profile data from %s.'), | ||
reader, | ||
symbols | ||
) | ||
return events, symbols | ||
end | ||
|
||
return safe_event_reader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters