aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ast/testdata
Commit message (Collapse)AuthorAgeFilesLines
* tools/syz-declextract: ignore files with non US-ASCII charsDmitry Vyukov2025-04-151-1/+1
|
* pkg/compiler: add automatic metaDmitry Vyukov2024-12-111-0/+1
| | | | | | Mark the whole file with "meta automatic" instead of marking each syscall. This reduces size of descriptions + allows to do special things with the whole file (e.g. we already treat auto consts specially).
* all: support || operator in syzlang if conditionJiao, Joey2024-11-132-0/+11
| | | | | | | | | | | ex. f3 field has logic or operator in if condition: conditional_struct { mask int32 f1 field1 (if[value[mask] & FIELD_FLAG1]) f2 int64 (if[value[mask] & FIELD_FLAG2]) f3 int64 (if[value[mask] == FIELD_FLAG1 || value[mask] == FIELD_FLAG2]) } [packed]
* compiler: support using int flags in field conditionsPaul Chaignon2024-03-011-1/+4
| | | | | | | | | | | | | | | | | | | Commit ed571339c6ff ("pkg/compiler: support if[expr] attributes") added support for conditional fields in structs and unions. Conditions however cannot refer to flags, as in the following example: struct { f0 flags[some_flags, int32] f1 int32 (if[value[f0] & FLAG1]) } [packed] It will fail to compile with: flags does not refer to an integer This commit adds support for that syntax. Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
* pkg/ast: support expressions with ast.TypeAleksandr Nogikh2024-02-192-1/+28
| | | | | | | | | | | | | | | | | | | | | So far they have the following grammar: OP = "==", "!=", "&" value-expr = value-expr OP value-expr | factor factor = "(" and-expr ")" | integer | identifier | string Operators are left associative, e.g. A & B & C is the same as (A & B) & C. Further restrictions will be imposed in pkg/compiler. This will help implement conditionally included fields.
* ast: accept idents in string flagsPaul Chaignon2023-12-052-2/+5
| | | | | | | | | | | A subsequent commit will allow string flags to refer to other string flags (nested definitions). For that to happen, the parser must accept idents as part of the string flags definitions, as follows. strflags0 = "foo", strflags1 strflags1 = "bar" Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
* pkg/ast, pkg/compiler: support per-file metadataDmitry Vyukov2022-04-292-1/+8
| | | | | | | | | | | | | | | | | | | | | We have a bunch of hacks in syz-extract, syz-sysgen and syz-check with respect to description files unsupported on some arches, or that must not be part of make extract. Add 2 meta attribtues to files: meta noextract Tells `make extract` to not extract constants for this file. Though, `syz-extract` can still be invoked manually on this file. meta arches["arch1", "arch2"] Restricts this file only to the given set of architectures. `make extract` and ``make generate` will not use it on other architectures. Later we can potentially use meta attributes to specify git tree/commit that must be used for extraction. Maybe something else. Fixes #2754
* pkg, prog: add per-field direction attributeNecip Fazil Yildiran2020-08-131-0/+13
|
* pkg/ast: extend testsDmitry Vyukov2020-05-012-79/+84
| | | | Test more functions that we currently don't test.
* pkg/ast: add call attributesDmitry Vyukov2020-04-191-0/+6
|
* pkg/ast: introduce hex-encoded string literalsDmitry Vyukov2020-02-101-4/+3
| | | | | | | | | | | | | The stringnozescapes does not make sense with filename, also we may need similar escaping for string flags. Handle escaped strings on ast level instead. This avoids introducing new type and works seamleassly with flags. As alternative I've also tried using strconv.Quote/Unquote but it leads to ugly half-escaped strings: "\xb0\x80s\xe8\xd4N\x91\xe3ڒ,\"C\x82D\xbb\x88\\i\xe2i\xc8\xe9\xd85\xb1\x14):M\xdcn" Make hex-encoded strings a separate string format instead.
* pkg/compiler: support complex len targetsDmitry Vyukov2019-05-141-1/+2
| | | | | | | | | | This change adds compiler support for complex path expressions in len targets. E.g. it allows to refer to a sibling field as len[parent_struct:field:another_field]. See the docs change for details. This is just a compiler change. The feature is not yet supported by the prog package.
* pkg/ast: refactor COLON handlingDmitry Vyukov2019-05-141-0/+1
| | | | | | | This prepared for handling of bytesize[parent:foo:bar] expressions by allowing multiple identifiers after colon. No functional changes for now, just preparation for storing more than one identifier after colon.
* pkg/compiler: support negative integersDmitry Vyukov2018-07-091-0/+1
| | | | | | 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.
* pkg/ast: support char constantsDmitry Vyukov2018-04-291-0/+3
| | | | | | | Frequently it's useful to do something like: int8['a':'z'] punctuation = ',', '-', ':'
* pkg/compiler: switch attributes from Ident to TypeDmitry Vyukov2018-03-051-0/+4
| | | | | This allows parametrized attributes like size[10]. But this is not used for now.
* pkg/compiler: allow use of empty stringsDmitry Vyukov2018-01-231-2/+2
| | | | This comes up in several contexts in netfilter.
* pkg/compiler: support type templatesDmitry Vyukov2018-01-131-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Netlink descriptions contain tons of code duplication, and need much more for proper descriptions. Introduce type templates to simplify writing such descriptions and remove code duplication. Note: type templates are experimental, have poor error handling and are subject to change. Type templates can be declared as follows: ``` type buffer[DIR] ptr[DIR, array[int8]] type fileoff[BASE] BASE type nlattr[TYPE, PAYLOAD] { nla_len len[parent, int16] nla_type const[TYPE, int16] payload PAYLOAD } [align_4] ``` and later used as follows: ``` syscall(a buffer[in], b fileoff[int64], c ptr[in, nlattr[FOO, int32]]) ```
* pkg/compiler: add builtin bool type aliasesDmitry Vyukov2018-01-081-2/+2
| | | | | | | | | | | | | | | | This adds builtin: type bool8 int8[0:1] type bool16 int16[0:1] type bool32 int32[0:1] type bool64 int64[0:1] type boolptr intptr[0:1] We used to use just int's for bools. But bool types provide several advantages: - make true/false probability equal - improve description expressiveness - reduce search space (we will take advantage of this later)
* sys: support type aliases (aka typedefs)Dmitry Vyukov2018-01-081-0/+5
| | | | | | | | | | | | | | | | | | | | | | Complex types that are often repeated can be given short type aliases using the following syntax: ``` type identifier underlying_type ``` For example: ``` type signalno int32[0:65] type net_port proc[20000, 4, int16be] ``` Then, type alias can be used instead of the underlying type in any contexts. Underlying type needs to be described as if it's a struct field, that is, with the base type if it's required. However, type alias can be used as syscall arguments as well. Underlying types are currently restricted to integer types, `ptr`, `ptr64`, `const`, `flags` and `proc` types.
* pkg/ast: prohibit empty stringsDmitry Vyukov2017-09-041-0/+6
| | | | This is currently unsupported and unused.
* pkg/ast: fix struct comment parsingDmitry Vyukov2017-09-041-0/+11
|
* pkg/compiler: move more const-processing code to compilerDmitry Vyukov2017-08-271-0/+2
|
* pkg/ast: new parser for sys descriptionsDmitry Vyukov2017-08-181-0/+28
The old parser in sys/sysparser is too hacky, difficult to extend and drops debug info too early, so that we can't produce proper error messages. Add a new parser that is build like a proper language parser and preserves full debug info for every token.