forked from LuaJIT/LuaJIT
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
profilers: introduce event reader module
There is no error-checking in profilers which results in raw Lua errors being reported in cases of non-existing paths or corrupt file structures. This patch adds a profiler-agnostic module for event parsing, which is going to be used to introduce user-friendly errors. It is impossible to enable it right now because it should be included in Tarantool's build procedure first. Part of tarantool/tarantool#9217 Part of tarantool/tarantool#5994
- Loading branch information
1 parent
7e5aca1
commit 357a24d
Showing
3 changed files
with
37 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
local bufread = require('utils.bufread') | ||
local symtab = require('utils.symtab') | ||
|
||
local function make_error_handler(fmt, inputfile) | ||
return function(err) | ||
io.stderr:write(string.format(fmt, inputfile)) | ||
io.stderr:write(string.format('\n\t%s\n', err)) | ||
os.exit(1, true) | ||
end | ||
end | ||
|
||
return function(parser, inputfile) | ||
local _, reader = xpcall( | ||
bufread.new, | ||
make_error_handler('Failed to open %s.', inputfile), | ||
inputfile | ||
) | ||
|
||
local _, symbols = xpcall( | ||
symtab.parse, | ||
make_error_handler('Failed to parse symtab from %s.', inputfile), | ||
reader | ||
) | ||
|
||
local _, events = xpcall( | ||
parser, | ||
make_error_handler('Failed to parse profile data from %s.', inputfile), | ||
reader, | ||
symbols | ||
) | ||
return events, symbols | ||
end |