From 250d8583ebbc94f93fe60465deb0ee3f02356af6 Mon Sep 17 00:00:00 2001 From: "Gabriele N. Tornetta" Date: Sat, 16 Mar 2024 15:04:17 +0000 Subject: [PATCH] fix: end line for CPython < 3.11 We fix the value of the line end exported in binary MOJO files for samples extracted from CPython < 3.11 and make sure that it is set to 0 to indicate that the information is not available. --- ChangeLog | 7 +++++++ configure.ac | 2 +- snap/snapcraft.yaml | 2 +- src/austin.h | 2 +- src/frame.h | 2 +- test/functional/test_mojo.py | 32 ++++++++++++++++++++++++++------ 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index ecf3b31..7831a1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-xx-xx v3.6.1 + + Bugfix: fixed a bug with the MOJO binary format that caused the line end + position to wrongly be set to a non-zero value for CPython < 3.11, where line + end information is not actually available. + + 2023-10-04 v3.6.0 Added support for CPython 3.12 diff --git a/configure.ac b/configure.ac index 9d1b0ce..7c2e490 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_PREREQ([2.69]) # from scripts.utils import get_current_version_from_changelog as version # print(f"AC_INIT([austin], [{version()}], [https://github.com/p403n1x87/austin/issues])") # ]]] -AC_INIT([austin], [3.6.0], [https://github.com/p403n1x87/austin/issues]) +AC_INIT([austin], [3.6.1], [https://github.com/p403n1x87/austin/issues]) # [[[end]]] AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADERS([config.h]) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index b25f684..eb2c327 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -4,7 +4,7 @@ base: core20 # from scripts.utils import get_current_version_from_changelog as version # print(f"version: '{version()}+git'") # ]]] -version: '3.6.0+git' +version: '3.6.1+git' # [[[end]]] summary: A Python frame stack sampler for CPython description: | diff --git a/src/austin.h b/src/austin.h index bfd860e..1201aa3 100644 --- a/src/austin.h +++ b/src/austin.h @@ -34,7 +34,7 @@ from scripts.utils import get_current_version_from_changelog as version print(f'#define VERSION "{version()}"') ]]] */ -#define VERSION "3.6.0" +#define VERSION "3.6.1" // [[[end]]] #endif diff --git a/src/frame.h b/src/frame.h index c92ad21..fe82c23 100644 --- a/src/frame.h +++ b/src/frame.h @@ -168,7 +168,7 @@ _frame_from_code_raddr(py_proc_t * py_proc, void * code_raddr, int lasti, python ssize_t len = 0; unsigned int lineno = V_FIELD(unsigned int, code, py_code, o_firstlineno); - unsigned int line_end = lineno; + unsigned int line_end = 0; unsigned int column = 0; unsigned int column_end = 0; diff --git a/test/functional/test_mojo.py b/test/functional/test_mojo.py index b2720b8..02eaeb7 100644 --- a/test/functional/test_mojo.py +++ b/test/functional/test_mojo.py @@ -21,13 +21,9 @@ # along with this program. If not, see . from pathlib import Path -from test.utils import allpythons -from test.utils import austin -from test.utils import python -from test.utils import target +from test.utils import allpythons, austin, python, target -from austin.format.mojo import MojoFile -from austin.format.mojo import MojoFrame +from austin.format.mojo import MojoFile, MojoFrame @allpythons(min=(3, 11)) @@ -56,3 +52,27 @@ def strip(f): ("lazy", 6, 6, 9, 19), ("", 17, 17, 5, 17), } + + +@allpythons(max=(3, 10)) +def test_mojo_no_column_data(py, tmp_path: Path): + """ + Test that no other location information is present apart from the line + number for Python versions prior to 3.11. + """ + datafile = tmp_path / "test_mojo_column.austin" + + result = austin( + "-i", "100", "-o", str(datafile), *python(py), target("column.py"), mojo=True + ) + assert result.returncode == 0, result.stderr or result.stdout + + def strip(f): + return + + with datafile.open("rb") as f: + assert { + (e.line_end, e.column, e.column_end) + for e in MojoFile(f).parse() + if isinstance(e, MojoFrame) + } == {(0, 0, 0)}