1
0

proj/test-return-values: Analyse call tree

This commit is contained in:
2025-05-07 10:33:46 +02:00
parent 2fff206f6a
commit 0c9e255433
5 changed files with 162 additions and 72 deletions

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations
from typing import Optional, TypedDict, NamedTuple, NotRequired, BinaryIO
from socketserver import UnixStreamServer, StreamRequestHandler, ThreadingMixIn
import os
@@ -41,14 +42,23 @@ class FunctionCallId:
ret_addr: int
obj_path: str
rel_ret_addr: int
sym_name: Optional[str]
src_file_name: Optional[str]
src_line_num: Optional[int]
sym_name: Optional[str] = None
src_file_name: Optional[str] = None
src_line_num: Optional[int] = None
@property
def obj_name(self) -> str:
return self.obj_path.split('/')[-1]
@staticmethod
def for_exit() -> FunctionCallId:
call_id = FunctionCallId()
call_id.func_name = 'exit'
call_id.obj_path = 'sys'
call_id.ret_addr = 0
call_id.rel_ret_addr = 0
return call_id
@property
def discriminator(self) -> str:
discr = [f'{self.obj_name}+0x{self.rel_ret_addr:x}']
@@ -69,6 +79,9 @@ class FunctionCallId:
def __str__(self) -> str:
return self.func_name + ', ' + self.discriminator
def __repr__(self) -> str:
return f'<{self}>'
class ThreadedUnixStreamServer(ThreadingMixIn, UnixStreamServer):
pass