makesyscalls.lua: improve syscall ordering validation

There were two separate issues here:

1.) #if/#else wasn't taken into account at all for maxsyscall figures, but
2.) We didn't validate contiguous syscall numbers anyways...

This kind of inconsistency is bad as we don't currently ensure explicit
indexing of, e.g., the sysent array if one syscall is unimplemented/missing.
This could be fixed and might be more robust, but it's also good to have the
"documentation" that comes from being explicit as to what the missing
syscalls are.

The new version looks much like the awk version; stash off the current
'last highest syscall seen' if we hit an #if, restore to that if we hit an
#else, and make sure that we're explicitly always defining the next syscall.

The logic at the tail end of process_syscall_def that moves maxsyscall has
been 'cleaned up' a little since we're now ensuring that it's monotonically
increasing earlier in the function. At the moment I think it's unlikely we'd
see range-definitions that are not UNIMPL, but there's no reason to
specifically handle that case for bumping maxsyscall there.

This change was provoked by reading the commit message for r363832 and
realizing that this validation hadn't been included in the initial rewrite
to lua.

Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D25945
This commit is contained in:
Kyle Evans 2020-08-04 21:49:13 +00:00
parent 784d8d8db0
commit 0bc1c0786b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=363869

View File

@ -35,7 +35,8 @@
local lfs = require("lfs")
local unistd = require("posix.unistd")
local maxsyscall = 0
local savesyscall = -1
local maxsyscall = -1
local generated_tag = "@" .. "generated"
-- Default configuration; any of these may get replaced by a configuration file
@ -442,6 +443,11 @@ local pattern_table = {
dump_prevline = true,
pattern = "^#",
process = function(line)
if line:find("^#%s*if") then
savesyscall = maxsyscall
elseif line:find("^#%s*else") then
maxsyscall = savesyscall
end
line = line .. "\n"
write_line('sysent', line)
write_line('sysdcl', line)
@ -916,6 +922,16 @@ process_syscall_def = function(line)
sysnum = nil
sysstart = tonumber(sysstart)
sysend = tonumber(sysend)
if sysstart ~= maxsyscall + 1 then
abort(1, "syscall number out of sync, missing " ..
maxsyscall + 1)
end
else
sysnum = tonumber(sysnum)
if sysnum ~= maxsyscall + 1 then
abort(1, "syscall number out of sync, missing " ..
maxsyscall + 1)
end
end
-- Split flags
@ -1093,15 +1109,14 @@ process_syscall_def = function(line)
handle_obsol(sysnum, funcname, funcomment)
elseif flags & known_flags["UNIMPL"] ~= 0 then
handle_unimpl(sysnum, sysstart, sysend, funcomment)
if sysend ~= nil and sysend > maxsyscall then
maxsyscall = sysend
end
else
abort(1, "Bad flags? " .. line)
end
if sysnum ~= nil and tonumber(sysnum) > maxsyscall then
maxsyscall = tonumber(sysnum)
if sysend ~= nil then
maxsyscall = sysend
elseif sysnum ~= nil then
maxsyscall = sysnum
end
end