aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler
Commit message (Collapse)AuthorAgeFilesLines
* pkg/compiler: don't warn about the same len twiceDmitry Vyukov2019-01-313-15/+74
| | | | Also add tests for warnings while we are here.
* pkg/csource: use 0 for missing syscall argsDmitry Vyukov2018-12-271-7/+16
| | | | | | | | | | | | | | We don't specify trailing unused args for some syscalls (e.g. ioctl that does not use its arg). Executor always filled tailing unsed args with 0's but pkg/csource didn't. Some such syscalls actually check that the unsed arg is 0 and as the result failed with C repro. We could statically check and eliminate all such cases, but it turns out the warning fires in 1500+ cases: https://gist.githubusercontent.com/dvyukov/e59ba1d9a211ee32fa0ba94fab86a943/raw/a3ace5a63f7281f0298f51ea9842ead1e4713418/gistfile1.txt So instead fill such args with 0's in pkg/csource too.
* executor: fix handling of big-endian bitfieldsDmitry Vyukov2018-12-083-5/+17
| | | | | Currently we apply big-endian-ness and bitfield-ness in the wrong order in copyin. This leads to totally bogus result. Fix this.
* pkg/compiler: add error handler in CollectUnusedMarco Vanotti2018-11-213-6/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * pkg/compiler: Add error handler in `CollectUnused`. This commit adds an error handler for the `CollectUnused` function. The error handler just panics on any error, but is useful for debugging. The error handler is used any time `comp` finds an error, and if it's missing, it will panic due to a `nil` pointer dereference. At least now we get a better understanding of the errors. The only user of `CollectUnused` is `sys/fuchsia/fidlgen`, which is failing now and will be fixed in a future commit. The output message looks like this: ``` panic: could not collect unused nodes. fidl_net-stack.txt:110:15: unknown type zx_chan_zircon_ethernet_Device_client ``` * pkg/compiler Better error handling in CollectUnused This commit changes the default error handler for compiler to `ast.LoggingHandler`, meaning that if `nil` is passed as an error handler, `LoggingHandler` will be used instead. `CollectUnused` now returns an error if any of the subfunctions produce errors. `fidlgen` is the only caller of `CollectUnused`, and now checks for errors as well. * pkg/compiler Add tests for CollectUnused This commit adds basic tests for the CollectUnused function. There's one test that checks that it returns the right nodes, and another one that makes sure that it returns errors when needed. To make the test clearer, I had to add the error handler as an explicit parameter in `CollectUnunsed`, instead of using the default one. This avoid printing garbage in the logs. The `TestCollectUnusedError` function uses a nopErrorHandler to avoid printing anything. * pkg/compiler fix presubmit warnings
* pkg/compiler: add vma64 typeDmitry Vyukov2018-11-172-1/+11
| | | | 8-byte vma is needed in several places in linux descriptions.
* sys/fuchsia: prune unused structs in syscall description generated by fidlgenDokyung Song2018-09-112-35/+57
| | | | | | | | After generating syscall description for fidl files using fidlgen, prune all unused structs using the exact same mechanism used by the compiler's check for unused structs. This allows the FIDL compiler to support modular compilation; it does not need to have global knowledge of whether each struct is used or not.
* sys/linux: add syz_execute_funcDmitry Vyukov2018-08-301-1/+3
| | | | | | The function executes random code. Update #310
* pkg/compiler: prohibit subargsDmitry Vyukov2018-08-103-0/+7
|
* pkg/compiler: refactor checkTypeDmitry Vyukov2018-08-022-31/+49
| | | | | | | checkType is too long and complex. Move basic type checks and args checks into separate functions. Update #538
* pkg/compiler: refactor checkNamesDmitry Vyukov2018-08-021-2/+10
| | | | | | Too complex. Split into 2 functions. Update #538
* pkg/compiler: refactor structGenDmitry Vyukov2018-08-021-62/+75
| | | | | | Still too complex. Split more. Update #538
* pkg/compiler: work around vet crashDmitry Vyukov2018-07-311-5/+6
| | | | | | | vetshadow not works, so enable it. Update https://github.com/golang/go/issues/26725 Update #538
* gometalinter: clean up vetshadowDmitry Vyukov2018-07-311-1/+1
| | | | | | | This just cleans up existing warnings. vetshadow is not enabled yet because it crashes. Update #538
* pkg/compiler: refactor genStructDescsDmitry Vyukov2018-07-311-116/+125
| | | | | | Reduce cyclomatic complexity of genStructDescs. Update #538
* prog: move MaxPids const to progDmitry Vyukov2018-07-251-3/+2
| | | | | The const may be needed by other packages. E.g. when checking manager config.
* executor: overhaulDmitry Vyukov2018-07-242-14/+14
| | | | | | | | | | | | | | | | | Make as much code as possible shared between all OSes. In particular main is now common across all OSes. Make more code shared between executor and csource (in particular, loop function and threaded execution logic). Also make loop and threaded logic shared across all OSes. Make more posix/unix code shared across OSes (e.g. signal handling, pthread creation, etc). Plus other changes along similar lines. Also support test OS in executor (based on portable posix) and add 4 arches that cover all execution modes (fork server/no fork server, shmem/no shmem). This change paves way for testing of executor code and allows to preserve consistency across OSes and executor/csource.
* pkg/compiler: fix error format stringDmitry Vyukov2018-07-131-1/+1
|
* pkg/compiler: support negative integersDmitry Vyukov2018-07-094-15/+41
| | | | | | Currently we have to use 0xffffffffffffffff to represent -1, and we can't express e.g. -20:20 int range. Support negative consts to fix both problems.
* prog, pkg/compiler: support fmt typeDmitry Vyukov2018-07-086-21/+128
| | | | | fmt type allows to convert intergers and resources to string representation.
* pkg/compiler: check for unused declarationsDmitry Vyukov2018-06-306-22/+127
| | | | | Error on unused structs/unions/resources/flags. Finds tons of bugs.
* prog: detect when flags are a bitmaskDmitry Vyukov2018-06-301-1/+12
|
* pkg/compiler: add optional builtin templateDmitry Vyukov2018-05-172-0/+6
| | | | | | | type optional[T] [ val T void void ] [varlen]
* pkg/compiler: detect duplicate fields in template structsDmitry Vyukov2018-05-172-3/+13
|
* all: get rid of underscores in identifiersDmitry Vyukov2018-05-071-5/+5
| | | | | | Underscores are against Go coding style. Update #538
* gometalinter: some fixes for unparamDmitry Vyukov2018-05-032-13/+9
| | | | | | But we still can't enable it as there are more [uninteresting] warnings. Update #538
* gometalinter: check unkeyed composite literalsDmitry Vyukov2018-05-031-1/+4
| | | | Update #538
* pkg/ast: support char constantsDmitry Vyukov2018-04-293-4/+16
| | | | | | | Frequently it's useful to do something like: int8['a':'z'] punctuation = ',', '-', ':'
* pkg/compiler: support non-zero terminated filenamesDmitry Vyukov2018-04-023-23/+27
| | | | | | | | | | | | | | | Now file names become: string[filename] with a possibility of using other string features: stringnoz[filename] string[filename, CONST_SIZE] and filename is left as type alias as it is commonly used: type filename string[filename]
* all: fix gometalinter warningsDmitry Vyukov2018-03-083-24/+26
| | | | Fix typos, non-canonical code, remove dead code, etc.
* pkg/compiler: allow specifying static size for filename'sDmitry Vyukov2018-03-051-0/+8
| | | | Sometimes filenames are embed into structs and need to take fixed space.
* pkg/compiler: support size attribute for unionsDmitry Vyukov2018-03-055-29/+58
|
* pkg/compiler: add size attribute for structsDmitry Vyukov2018-03-0510-33/+162
| | | | The size attribute allows to pad a struct up to the specified size.
* pkg/compiler: switch attributes from Ident to TypeDmitry Vyukov2018-03-053-8/+32
| | | | | This allows parametrized attributes like size[10]. But this is not used for now.
* pkg/compiler: fix alignment corner caseDmitry Vyukov2018-02-251-1/+3
| | | | | Fix alignemnt calculation for packed structs with alignment and bitfields. Amusingly this affected only a single real struct -- ipv6_fragment_ext_header.
* pkg/compiler: don't assign call IDs staticallyDmitry Vyukov2018-02-251-3/+0
| | | | | | IDs change whenever a call is added or removed, this leads to large diffs unnecessarly. Assign IDs dynamically.
* pkg/compiler: prohibit len of other union optionsDmitry Vyukov2018-02-232-1/+10
|
* pkg/compiler: allow unions as syscall argumentsDmitry Vyukov2018-02-235-57/+101
| | | | | If all union options can be syscall arguments, allow the union itself as syscall argument.
* pkg/compiler: fix corner case in alignment calculationDmitry Vyukov2018-02-191-1/+1
|
* pkg/compiler: support template template argumentsDmitry Vyukov2018-02-173-4/+56
| | | | Can be useful for netfilter descriptions.
* pkg/compiler: allow len of var-len arraysDmitry Vyukov2018-02-173-3/+3
| | | | | All netfilter subsystems use this unfortunately, so demote this to a warning.
* sys/syz-extract: save unsupported consts to the const filesDmitry Vyukov2018-02-011-10/+13
| | | | | | | | | | | We currently print unsupported consts to console during make extract. But this is not very useful as there are too many output now. This also does not allow to understand what's unsupported in newly checked-in descriptions, or what's unsupported in all current decriptions. Save unsupported consts to the const files instead. This solves all of the above problems.
* pkg/compiler: allow unions with only 1 fieldDmitry Vyukov2018-01-273-14/+15
| | | | | | | | | | | | | Unions with only 1 field are not actually unions, and can always be replaced with the option type. However, they are still useful when there will be more options in future but currently only 1 is described. Alternatives are: - not using union (but then all existing programs will be broken when union is finally introduced) - adding a fake field (ugly and reduces fuzzer efficiency) Allow unions with only 1 field.
* pkg/compiler, prog: fix template parent lensDmitry Vyukov2018-01-241-6/+3
| | | | | | | It's possible that a struct can have 2+ parents, which is the same template (differs only by arguments). See the new test case. Support such case.
* pkg/compiler: fix len of parent template structDmitry Vyukov2018-01-232-3/+26
| | | | | | | | | | | | | | | | | | | | | Consider the following example: type len_templ1[DATA1, DATA2] { data DATA1 inner len_temp2[DATA2] } type len_temp2[DATA] { data DATA len len[len_templ1, int8] } Here len refers to a parent struct, but the struct is a template, so it's actual name is something like "len_templ1[int8, int16]". Currently this does not work as compiler barks at incorrect len target. Make this work.
* pkg/compiler: allow use of empty stringsDmitry Vyukov2018-01-233-11/+26
| | | | This comes up in several contexts in netfilter.
* pkg/compiler: allow strings as template argumentsDmitry Vyukov2018-01-233-7/+3
| | | | Needed for netfilter descriptions.
* pkg/compiler: support non-zero-terminated stringsDmitry Vyukov2018-01-183-32/+61
| | | | Add stringnoz type.
* pkg/compiler: allow string/array as template typeDmitry Vyukov2018-01-131-7/+9
|
* sys/syz-sysgen: don't generate syz_ syscall numbersDmitry Vyukov2018-01-132-30/+4
| | | | They don't seem to be used today.
* pkg/compiler: support void typeDmitry Vyukov2018-01-135-30/+124
| | | | | | "void": type with static size 0 mostly useful inside of templates and varlen unions can't be syscall argument