diff --git a/austin/format/mojo.py b/austin/format/mojo.py index 2695b1d..a9925a3 100644 --- a/austin/format/mojo.py +++ b/austin/format/mojo.py @@ -135,11 +135,18 @@ class MojoStack(MojoEvent): """MOJO stack.""" pid: int + iid: int tid: str def to_austin(self) -> str: """Convert the event to Austin format.""" - return f"P{self.pid};T{int(self.tid, 16)}" + try: + tid = int(self.tid, 16) + except ValueError: + tid = self.tid + return ( + f"P{self.pid};T{self.iid}:{tid}" if self.iid >= 0 else f"P{self.pid};T{tid}" + ) @dataclass(frozen=True, eq=True) @@ -325,7 +332,9 @@ def parse_stack(self) -> t.Generator[t.Union[MojoEvent, int], None, None]: yield from self._emit_metrics() self._pid = pid = self.read_int() - yield MojoStack(pid, self.read_string()) + iid = self.read_int() if self.mojo_version >= 3 else -1 + + yield MojoStack(pid, iid, self.read_string()) def _lookup_string(self) -> MojoString: n = self.read_int() diff --git a/test/format/test_mojo.py b/test/format/test_mojo.py index f152c48..f1ec883 100644 --- a/test/format/test_mojo.py +++ b/test/format/test_mojo.py @@ -31,6 +31,7 @@ from austin.format.mojo import MojoFile from austin.format.mojo import MojoFrame +from austin.format.mojo import MojoStack from austin.format.mojo import MojoString from austin.format.mojo import MojoStringReference from austin.format.mojo import main @@ -161,3 +162,8 @@ def test_mojo_column_info(): column_end=17, ), } + + +def test_mojo_stack(): + assert MojoStack(1, -1, "noiid").to_austin() == "P1;Tnoiid" + assert MojoStack(1, 2, "iid").to_austin() == "P1;T2:iid"