aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-declextract/testdata
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2025-01-17 10:39:46 +0100
committerDmitry Vyukov <dvyukov@google.com>2025-01-17 18:09:32 +0000
commit38ee454540b9b41d5cc173871dfbf7dd140e8abc (patch)
treea7f5f04a7a9286f9eeca01520b51012e3606bb99 /tools/syz-declextract/testdata
parent953d1c45a16b7284725e337b47369a8ab111bab4 (diff)
pkg/declextract: move const handling logic from the clang tool
Export raw info about consts from the clang tool, and let the Go part handle it. The less logic is in the clang tool, the better. Also this will allow to remove unused includes when we know which consts we ended up using. The more includes we include, the higher the chances we include something that's broken.
Diffstat (limited to 'tools/syz-declextract/testdata')
-rw-r--r--tools/syz-declextract/testdata/file_operations.c.json28
-rw-r--r--tools/syz-declextract/testdata/io_uring.c.json23
-rw-r--r--tools/syz-declextract/testdata/netlink.c.json62
-rw-r--r--tools/syz-declextract/testdata/types.c.json11
4 files changed, 108 insertions, 16 deletions
diff --git a/tools/syz-declextract/testdata/file_operations.c.json b/tools/syz-declextract/testdata/file_operations.c.json
index 94ad7bef5..df1c9a20f 100644
--- a/tools/syz-declextract/testdata/file_operations.c.json
+++ b/tools/syz-declextract/testdata/file_operations.c.json
@@ -47,8 +47,32 @@
"is_static": true
}
],
- "includes": [
- "include/uapi/file_operations.h"
+ "consts": [
+ {
+ "name": "FOO_IOCTL1",
+ "filename": "include/uapi/file_operations.h",
+ "value": 25345
+ },
+ {
+ "name": "FOO_IOCTL2",
+ "filename": "include/uapi/file_operations.h",
+ "value": 2147771138
+ },
+ {
+ "name": "FOO_IOCTL3",
+ "filename": "include/uapi/file_operations.h",
+ "value": 2148033283
+ },
+ {
+ "name": "FOO_IOCTL4",
+ "filename": "include/uapi/file_operations.h",
+ "value": 1074291460
+ },
+ {
+ "name": "FOO_IOCTL5",
+ "filename": "include/uapi/file_operations.h",
+ "value": 3221775109
+ }
],
"structs": [
{
diff --git a/tools/syz-declextract/testdata/io_uring.c.json b/tools/syz-declextract/testdata/io_uring.c.json
index 3f0a74a95..da91ce1b6 100644
--- a/tools/syz-declextract/testdata/io_uring.c.json
+++ b/tools/syz-declextract/testdata/io_uring.c.json
@@ -29,8 +29,27 @@
"file": "io_uring.c"
}
],
- "includes": [
- "include/uapi/io_uring.h"
+ "consts": [
+ {
+ "name": "IORING_OP_NOP",
+ "filename": "include/uapi/io_uring.h",
+ "value": 0
+ },
+ {
+ "name": "IORING_OP_NOT_SUPPORTED",
+ "filename": "include/uapi/io_uring.h",
+ "value": 3
+ },
+ {
+ "name": "IORING_OP_READV",
+ "filename": "include/uapi/io_uring.h",
+ "value": 1
+ },
+ {
+ "name": "IORING_OP_WRITEV",
+ "filename": "include/uapi/io_uring.h",
+ "value": 2
+ }
],
"iouring_ops": [
{
diff --git a/tools/syz-declextract/testdata/netlink.c.json b/tools/syz-declextract/testdata/netlink.c.json
index 4233eab7d..e1c2754b1 100644
--- a/tools/syz-declextract/testdata/netlink.c.json
+++ b/tools/syz-declextract/testdata/netlink.c.json
@@ -37,25 +37,71 @@
"is_static": true
}
],
- "includes": [
- "include/uapi/netlink_family.h"
- ],
- "defines": [
+ "consts": [
{
"name": "NETLINK_BAR_CMD_FOO",
- "value": "0"
+ "filename": "netlink.c",
+ "value": 0
+ },
+ {
+ "name": "NETLINK_FOO_ATTR1",
+ "filename": "include/uapi/netlink_family.h",
+ "value": 0
+ },
+ {
+ "name": "NETLINK_FOO_ATTR2",
+ "filename": "include/uapi/netlink_family.h",
+ "value": 1
+ },
+ {
+ "name": "NETLINK_FOO_ATTR3",
+ "filename": "include/uapi/netlink_family.h",
+ "value": 4
+ },
+ {
+ "name": "NETLINK_FOO_ATTR4",
+ "filename": "include/uapi/netlink_family.h",
+ "value": 5
+ },
+ {
+ "name": "NETLINK_FOO_ATTR5",
+ "filename": "include/uapi/netlink_family.h",
+ "value": 6
+ },
+ {
+ "name": "NETLINK_FOO_ATTR6",
+ "filename": "include/uapi/netlink_family.h",
+ "value": 7
+ },
+ {
+ "name": "NETLINK_FOO_ATTR7",
+ "filename": "include/uapi/netlink_family.h",
+ "value": 8
+ },
+ {
+ "name": "NETLINK_FOO_CMD_BAR",
+ "filename": "include/uapi/netlink_family.h",
+ "value": 1
+ },
+ {
+ "name": "NETLINK_FOO_CMD_FOO",
+ "filename": "include/uapi/netlink_family.h",
+ "value": 0
},
{
"name": "NETLINK_FOO_NESTED_ATTR1",
- "value": "0"
+ "filename": "netlink.c",
+ "value": 0
},
{
"name": "NETLINK_FOO_NESTED_ATTR2",
- "value": "1"
+ "filename": "netlink.c",
+ "value": 1
},
{
"name": "NETLINK_NOPOLICY_CMD",
- "value": "0"
+ "filename": "netlink.c",
+ "value": 0
}
],
"structs": [
diff --git a/tools/syz-declextract/testdata/types.c.json b/tools/syz-declextract/testdata/types.c.json
index a5a7088db..82d45e3fe 100644
--- a/tools/syz-declextract/testdata/types.c.json
+++ b/tools/syz-declextract/testdata/types.c.json
@@ -111,18 +111,21 @@
]
}
],
- "defines": [
+ "consts": [
{
"name": "a",
- "value": "0"
+ "filename": "types.c",
+ "value": 0
},
{
"name": "b",
- "value": "1"
+ "filename": "types.c",
+ "value": 1
},
{
"name": "c",
- "value": "2"
+ "filename": "types.c",
+ "value": 2
}
],
"enums": [