(params)
| 198 | return None |
| 199 | |
| 200 | def query_local_database(params): |
| 201 | if not context.local_libcdb or not params.get("symbols"): |
| 202 | return None |
| 203 | |
| 204 | localdb = Path(context.local_libcdb) |
| 205 | if not localdb.is_dir(): |
| 206 | return None |
| 207 | |
| 208 | res = [] |
| 209 | query_syms = params["symbols"] |
| 210 | |
| 211 | # Loop through each '.symbols' file in the local database |
| 212 | # Make sure `Path.rglod` order stable |
| 213 | for symbol_file in sorted(localdb.rglob("*.symbols"), key=lambda x: x.as_posix()): |
| 214 | libc_syms = _parse_libc_symbol(symbol_file) |
| 215 | |
| 216 | matched = 0 |
| 217 | for name, addr in query_syms.items(): |
| 218 | if isinstance(addr, str): |
| 219 | addr = int(addr, 16) |
| 220 | |
| 221 | # Compare last 12 bits |
| 222 | if libc_syms.get(name) and (libc_syms.get(name) & 0xfff) == (addr & 0xfff): |
| 223 | matched += 1 |
| 224 | else: |
| 225 | # aborting this loop once there was a mismatch. |
| 226 | break |
| 227 | |
| 228 | # Check if all symbols have been matched |
| 229 | if matched == len(query_syms): |
| 230 | libs_id = symbol_file.stem |
| 231 | libc_path = symbol_file.parent / ("%s.so" % libs_id) |
| 232 | libs_url = read(symbol_file.parent / ("%s.url" % libs_id)).decode().strip() |
| 233 | res.append(_pack_libs_info(libc_path, libs_id, libs_url, libc_syms)) |
| 234 | |
| 235 | return res |
| 236 | |
| 237 | PROVIDERS = { |
| 238 | "offline": [provider_local_system, provider_local_database], |
no test coverage detected