From a5766228c092489e4df1463389f99f9c7350b997 Mon Sep 17 00:00:00 2001 From: Kemal Akkoyun Date: Sat, 24 Feb 2024 08:47:27 +0100 Subject: [PATCH] Fix CFrame issue Add 3.12 tests Signed-off-by: Kemal Akkoyun --- pkg/python/datamap.go | 10 ++-- pkg/python/layout/amd64/3.12.0 - 3.12.2.yaml | 4 +- pkg/python/layout/arm64/3.12.0 - 3.12.2.yaml | 4 +- pkg/python/python_test.go | 48 ++++++++++++++++++++ 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/pkg/python/datamap.go b/pkg/python/datamap.go index 6f81088..6e753a0 100644 --- a/pkg/python/datamap.go +++ b/pkg/python/datamap.go @@ -71,7 +71,7 @@ func (p python27) Layout() runtimedata.RuntimeData { CFrame: doesNotExist, }, PyCFrame: PyCFrame{ - CurrentFrame: 0, // TODO(kakkoyun): Set -1 (next iteration). + CurrentFrame: 0, }, PyInterpreterState: PyInterpreterState{ TStateHead: p.PyInterpreterStateTstateHead, @@ -139,7 +139,7 @@ func (p python33_39) Layout() runtimedata.RuntimeData { CFrame: doesNotExist, }, PyCFrame: PyCFrame{ - CurrentFrame: 0, // TODO(kakkoyun): Set -1 (next iteration). + CurrentFrame: 0, }, PyInterpreterState: PyInterpreterState{ TStateHead: p.PyInterpreterStateTstateHead, @@ -207,7 +207,7 @@ func (p python310) Layout() runtimedata.RuntimeData { CFrame: doesNotExist, }, PyCFrame: PyCFrame{ - CurrentFrame: 0, // TODO(kakkoyun): Set -1 (next iteration). + CurrentFrame: 0, }, PyInterpreterState: PyInterpreterState{ TStateHead: p.PyInterpreterStateTstateHead, @@ -322,7 +322,7 @@ type python312 struct { PyFrameObjectFLocalsplus int64 `offsetof:"_PyInterpreterFrame.localsplus"` PyCodeObjectCoFilename int64 `offsetof:"PyCodeObject.co_filename"` PyCodeObjectCoName int64 `offsetof:"PyCodeObject.co_name"` - PyCodeObjectCoVarNames int64 `offsetof:"PyCodeObject.co_localsplusnames"` + PyCodeObjectCoVarNames int64 `offsetof:"PyCodeObject.co_varnames"` PyCodeObjectCoFirstlineno int64 `offsetof:"PyCodeObject.co_firstlineno"` PyTupleObjectObItem int64 `offsetof:"PyTupleObject.ob_item"` } @@ -348,7 +348,7 @@ func (p python312) Layout() runtimedata.RuntimeData { CFrame: p.PyThreadStateCFrame, }, PyCFrame: PyCFrame{ - CurrentFrame: doesNotExist, + CurrentFrame: 0, }, PyInterpreterState: PyInterpreterState{ TStateHead: p.PyInterpreterStateTstateHead + p.PyInterpreterStateIsPythreadsHead, diff --git a/pkg/python/layout/amd64/3.12.0 - 3.12.2.yaml b/pkg/python/layout/amd64/3.12.0 - 3.12.2.yaml index 15a0537..a370f69 100644 --- a/pkg/python/layout/amd64/3.12.0 - 3.12.2.yaml +++ b/pkg/python/layout/amd64/3.12.0 - 3.12.2.yaml @@ -1,10 +1,10 @@ py_cframe: - current_frame: -1 + current_frame: 0 py_code_object: co_filename: 112 co_firstlineno: 68 co_name: 120 - co_varnames: 96 + co_varnames: 0 py_frame_object: f_back: 8 f_code: 0 diff --git a/pkg/python/layout/arm64/3.12.0 - 3.12.2.yaml b/pkg/python/layout/arm64/3.12.0 - 3.12.2.yaml index 15a0537..a370f69 100644 --- a/pkg/python/layout/arm64/3.12.0 - 3.12.2.yaml +++ b/pkg/python/layout/arm64/3.12.0 - 3.12.2.yaml @@ -1,10 +1,10 @@ py_cframe: - current_frame: -1 + current_frame: 0 py_code_object: co_filename: 112 co_firstlineno: 68 co_name: 120 - co_varnames: 96 + co_varnames: 0 py_frame_object: f_back: 8 f_code: 0 diff --git a/pkg/python/python_test.go b/pkg/python/python_test.go index 919438e..bbcd31d 100644 --- a/pkg/python/python_test.go +++ b/pkg/python/python_test.go @@ -150,6 +150,54 @@ func TestGetLayout(t *testing.T) { }, }, }, + { + version: "3.12.2", + archs: allSupportedArchs, + want: &Layout{ + PyObject: PyObject{ + ObType: 8, + }, + PyString: PyString{ + Data: 40, + Size: -1, + }, + PyTypeObject: PyTypeObject{ + TPName: 24, + }, + PyThreadState: PyThreadState{ + Next: 8, + Interp: 16, + Frame: -1, + ThreadID: 136, + NativeThreadID: 144, + CFrame: 56, + }, + PyCFrame: PyCFrame{ + CurrentFrame: 0, + }, + PyInterpreterState: PyInterpreterState{ + TStateHead: 72, + }, + PyRuntimeState: PyRuntimeState{ + InterpMain: 48, + }, + PyFrameObject: PyFrameObject{ + FBack: 8, + FCode: 0, + FLineno: -1, + FLocalsplus: 72, + }, + PyCodeObject: PyCodeObject{ + CoFilename: 112, + CoName: 120, + CoVarnames: 0, + CoFirstlineno: 68, + }, + PyTupleObject: PyTupleObject{ + ObItem: 24, + }, + }, + }, } for _, tt := range tests { var (