Look up a stack trace by its hash from kstacks/ustacks CSV
(self, stack_hash: str, is_kernel: bool = True)
| 274 | return [] |
| 275 | |
| 276 | def lookup_stack_trace(self, stack_hash: str, is_kernel: bool = True) -> Optional[str]: |
| 277 | """Look up a stack trace by its hash from kstacks/ustacks CSV""" |
| 278 | csv_type = 'kstacks' if is_kernel else 'ustacks' |
| 279 | csv_pattern = f'xcapture_{csv_type}_*.csv' |
| 280 | csv_path = str(self.data_source.datadir / csv_pattern) |
| 281 | |
| 282 | # Use the correct column names based on stack type |
| 283 | hash_col = 'KSTACK_HASH' if is_kernel else 'USTACK_HASH' |
| 284 | syms_col = 'KSTACK_SYMS' if is_kernel else 'USTACK_SYMS' |
| 285 | |
| 286 | query = f""" |
| 287 | SELECT {syms_col} |
| 288 | FROM read_csv_auto('{csv_path}') |
| 289 | WHERE {hash_col} = '{stack_hash}' |
| 290 | LIMIT 1 |
| 291 | """ |
| 292 | |
| 293 | conn = self.data_source.connect() |
| 294 | try: |
| 295 | result = conn.execute(query).fetchone() |
| 296 | if result and result[0]: |
| 297 | return result[0] |
| 298 | return None |
| 299 | except Exception as e: |
| 300 | if self.logger: |
| 301 | self.logger.error(f"Error looking up stack trace: {e}") |
| 302 | return None |
| 303 | |
| 304 | def clear_cache(self): |
| 305 | """Clear the query template cache""" |