(Defs, DefsDict, Arch, FilePath)
| 119 | SyscallDefinitions[Name].append(Def) |
| 120 | |
| 121 | def ParseCommonArchSyscalls(Defs, DefsDict, Arch, FilePath): |
| 122 | global NumArches |
| 123 | global SyscallDefinitions |
| 124 | syscall_file = open(FilePath, "r") |
| 125 | text_lines = syscall_file.readlines() |
| 126 | syscall_file.close() |
| 127 | |
| 128 | NumArches += 1 |
| 129 | SyscallNumbers = {} |
| 130 | for line in text_lines: |
| 131 | line = line.strip() |
| 132 | |
| 133 | if len(line) == 0: |
| 134 | continue |
| 135 | |
| 136 | # Check for NR defines |
| 137 | if (line.startswith("#define __NR_") or |
| 138 | line.startswith("#define __NR3264_")): |
| 139 | # This line is defining a syscall for us |
| 140 | # eg: #define __NR_io_setup 0 |
| 141 | line = line.removeprefix("#define __NR_") |
| 142 | line = line.removeprefix("#define __NR3264_") |
| 143 | split_text = line.split(" ") |
| 144 | |
| 145 | # Store this for later |
| 146 | Name = split_text[0] |
| 147 | |
| 148 | # Need to do len here since some lines are multiple spaces between define name and value |
| 149 | SyscallNumbers[Name] = split_text[len(split_text) - 1] |
| 150 | continue |
| 151 | |
| 152 | BeginsString = "" |
| 153 | # Check for __SC_COMP and __SYSCALL defines |
| 154 | if line.startswith("__SYSCALL("): |
| 155 | BeginsString = "__SYSCALL(" |
| 156 | elif line.startswith("__SC_COMP("): |
| 157 | BeginsString = "__SC_COMP(" |
| 158 | elif line.startswith("__SC_3264("): |
| 159 | BeginsString = "__SC_3264(" |
| 160 | elif line.startswith("__SC_COMP_3264("): |
| 161 | BeginsString = "__SC_COMP_3264(" |
| 162 | else: |
| 163 | continue |
| 164 | |
| 165 | line = line.removeprefix(BeginsString) |
| 166 | |
| 167 | if line.startswith("__NR_"): |
| 168 | BeginsString = "__NR_" |
| 169 | elif line.startswith("__NR3264_"): |
| 170 | BeginsString = "__NR3264_" |
| 171 | |
| 172 | line = line.removeprefix(BeginsString) |
| 173 | |
| 174 | split_text = line.split(",") |
| 175 | |
| 176 | Name = split_text[0] |
| 177 | Num = SyscallNumbers[Name] |
| 178 | ABI = Arch |
no test coverage detected