Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fecb1db

Browse files
committed
Drop the C checks
1 parent c9813b1 commit fecb1db

3 files changed

Lines changed: 1 addition & 133 deletions

File tree

Lib/test/test_perf_profiler.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
assert_python_failure,
1313
assert_python_ok,
1414
)
15-
from test.support import import_helper
1615
from test.support.os_helper import temp_dir
1716

1817

@@ -845,17 +844,5 @@ def test_jitdump_unwinding_info(self):
845844
self.assertTrue(any("my_test_func" in name for name in regions))
846845

847846

848-
class TestTrampolineEhframeHeader(unittest.TestCase):
849-
"""Structural checks on the generated trampoline_ehframe.h data."""
850-
851-
def test_generated_header_structure(self):
852-
_testinternalcapi = import_helper.import_module("_testinternalcapi")
853-
check = getattr(_testinternalcapi, "test_trampoline_ehframe", None)
854-
if check is None:
855-
self.skipTest("_testinternalcapi built without the perf trampoline")
856-
# Raises AssertionError describing the first failed check.
857-
check()
858-
859-
860847
if __name__ == "__main__":
861848
unittest.main()

Makefile.pre.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3471,7 +3471,7 @@ MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo.
34713471
MODULE__SSL_DEPS=$(srcdir)/Modules/_ssl.h $(srcdir)/Modules/_openssl_mem.h $(srcdir)/Modules/_ssl/cert.c $(srcdir)/Modules/_ssl/debughelpers.c $(srcdir)/Modules/_ssl/misc.c $(srcdir)/Modules/_ssl_data_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h
34723472
MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/_testcapi/parts.h $(srcdir)/Modules/_testcapi/util.h
34733473
MODULE__TESTLIMITEDCAPI_DEPS=$(srcdir)/Modules/_testlimitedcapi/testcapi_long.h $(srcdir)/Modules/_testlimitedcapi/parts.h $(srcdir)/Modules/_testlimitedcapi/util.h
3474-
MODULE__TESTINTERNALCAPI_DEPS=$(srcdir)/Modules/_testinternalcapi/parts.h $(srcdir)/Parser/tokenizer/cursor.h $(srcdir)/Parser/tokenizer/source.h $(srcdir)/Python/ceval.h $(srcdir)/Modules/_testinternalcapi/test_targets.h $(srcdir)/Modules/_testinternalcapi/test_cases.c.h $(TRAMPOLINE_EHFRAME_H)
3474+
MODULE__TESTINTERNALCAPI_DEPS=$(srcdir)/Modules/_testinternalcapi/parts.h $(srcdir)/Parser/tokenizer/cursor.h $(srcdir)/Parser/tokenizer/source.h $(srcdir)/Python/ceval.h $(srcdir)/Modules/_testinternalcapi/test_targets.h $(srcdir)/Modules/_testinternalcapi/test_cases.c.h
34753475
MODULE__SQLITE3_DEPS=$(srcdir)/Modules/_sqlite/connection.h $(srcdir)/Modules/_sqlite/cursor.h $(srcdir)/Modules/_sqlite/microprotocols.h $(srcdir)/Modules/_sqlite/module.h $(srcdir)/Modules/_sqlite/prepare_protocol.h $(srcdir)/Modules/_sqlite/row.h $(srcdir)/Modules/_sqlite/util.h
34763476
MODULE__ZSTD_DEPS=$(srcdir)/Modules/_zstd/_zstdmodule.h $(srcdir)/Modules/_zstd/buffer.h $(srcdir)/Modules/_zstd/zstddict.h
34773477

Modules/_testinternalcapi.c

Lines changed: 0 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "pycore_instruction_sequence.h" // _PyInstructionSequence_New()
3131
#include "pycore_interpframe.h" // _PyFrame_GetFunction()
3232
#include "pycore_jit.h" // _PyJIT_AddressInJitCode()
33-
#include "pycore_jit_unwind.h" // DWRF_EH_PE_* constants
3433
#include "pycore_object.h" // _PyObject_IsFreed()
3534
#include "pycore_optimizer.h" // _Py_Executor_DependsOn
3635
#include "pycore_pathconfig.h" // _PyPathConfig_ClearGlobal()
@@ -2719,121 +2718,6 @@ _testinternalcapi_test_long_numbits_impl(PyObject *module)
27192718
Py_RETURN_NONE;
27202719
}
27212720

2722-
#if defined(PY_HAVE_PERF_TRAMPOLINE)
2723-
#include "trampoline_ehframe.h"
2724-
2725-
/* Structural checks on the generated perf trampoline .eh_frame and the
2726-
* field offsets Python/jit_unwind.c patches. Raises instead of assert()
2727-
* so the checks also run in release builds. */
2728-
static PyObject *
2729-
test_trampoline_ehframe(PyObject *self, PyObject *Py_UNUSED(args))
2730-
{
2731-
#define CHECK(cond, msg) \
2732-
do { \
2733-
if (!(cond)) { \
2734-
PyErr_SetString(PyExc_AssertionError, \
2735-
"trampoline_ehframe: " msg); \
2736-
return NULL; \
2737-
} \
2738-
} while (0)
2739-
2740-
const uint8_t *data = _trampoline_ehframe;
2741-
size_t size = TRAMPOLINE_EHFRAME_SIZE;
2742-
size_t field_size = TRAMPOLINE_EHFRAME_FDE_FIELD_SIZE;
2743-
2744-
CHECK(field_size == 4 || field_size == 8, "unsupported FDE field size");
2745-
CHECK(size >= 8 + 8 + 2 * field_size + 1, "data too small for a CIE and an FDE");
2746-
2747-
/* CIE: length, CIE_id == 0, version 1, augmentation "zR". */
2748-
uint32_t cie_length;
2749-
memcpy(&cie_length, data, sizeof(cie_length));
2750-
CHECK(cie_length > 0 && cie_length < size, "bad CIE length");
2751-
2752-
uint32_t cie_id;
2753-
memcpy(&cie_id, data + 4, sizeof(cie_id));
2754-
CHECK(cie_id == 0, "first entry is not a CIE");
2755-
2756-
CHECK(data[8] == 1, "CIE version is not 1");
2757-
CHECK(data[9] == 'z' && data[10] == 'R' && data[11] == '\0',
2758-
"CIE augmentation is not \"zR\"");
2759-
2760-
/* Exactly one FDE must follow the CIE, and the walk below must stay
2761-
* inside the data. */
2762-
size_t cie_total = 4 + cie_length;
2763-
CHECK(cie_total + 8 + 2 * field_size <= size,
2764-
"no room for an FDE after the CIE");
2765-
2766-
/* FDE pointer encoding byte: skip version(1), "zR\0"(3), code_align
2767-
* (ULEB128), data_align (SLEB128), RA column (1 byte in version 1),
2768-
* augmentation data length (ULEB128). */
2769-
size_t pos = 12;
2770-
while (pos < cie_total && (data[pos] & 0x80)) { /* code alignment */
2771-
pos++;
2772-
}
2773-
pos++;
2774-
while (pos < cie_total && (data[pos] & 0x80)) { /* data alignment */
2775-
pos++;
2776-
}
2777-
pos++;
2778-
pos++; /* RA column */
2779-
/* Augmentation data length (ULEB128) must be 1: the encoding byte. */
2780-
uint32_t aug_length = 0;
2781-
int shift = 0;
2782-
while (pos < cie_total && (data[pos] & 0x80)) {
2783-
CHECK(shift < 28, "CIE augmentation data length is too long");
2784-
aug_length |= (uint32_t)(data[pos] & 0x7f) << shift;
2785-
shift += 7;
2786-
pos++;
2787-
}
2788-
CHECK(pos < cie_total, "CIE augmentation data length is truncated");
2789-
CHECK((uint32_t)(data[pos] & 0x7f) <= (UINT32_MAX >> shift),
2790-
"CIE augmentation data length overflows");
2791-
aug_length |= (uint32_t)(data[pos] & 0x7f) << shift;
2792-
pos++;
2793-
CHECK(aug_length == 1 && pos < cie_total,
2794-
"CIE augmentation data length is not 1");
2795-
uint8_t fde_enc = data[pos];
2796-
CHECK(fde_enc == (DWRF_EH_PE_pcrel | DWRF_EH_PE_sdata4)
2797-
|| fde_enc == (DWRF_EH_PE_pcrel | DWRF_EH_PE_absptr),
2798-
"unsupported FDE pointer encoding");
2799-
size_t enc_field_size = (fde_enc & 0x0f) == DWRF_EH_PE_sdata4 ? 4 : 8;
2800-
CHECK(enc_field_size == field_size,
2801-
"FDE field size does not match the CIE pointer encoding");
2802-
2803-
/* The FDE ends exactly at the end of the data. */
2804-
uint32_t fde_length;
2805-
memcpy(&fde_length, data + cie_total, sizeof(fde_length));
2806-
CHECK(fde_length > 0, "FDE length is zero");
2807-
CHECK(cie_total + 4 + fde_length == size,
2808-
"FDE does not end at the end of the data");
2809-
2810-
/* The CIE pointer is the distance from its own field back to the CIE. */
2811-
uint32_t fde_cie_ptr;
2812-
memcpy(&fde_cie_ptr, data + cie_total + 4, sizeof(fde_cie_ptr));
2813-
CHECK(fde_cie_ptr == cie_total + 4, "FDE CIE pointer does not point at the CIE");
2814-
2815-
/* The runtime patches initial_location and address_range at the
2816-
* recorded offsets. They must be the two fields after the CIE pointer
2817-
* and must be zeroed placeholders in the header. */
2818-
CHECK(TRAMPOLINE_EHFRAME_FDE_PC_OFFSET == cie_total + 8,
2819-
"FDE initial_location offset is wrong");
2820-
CHECK(TRAMPOLINE_EHFRAME_FDE_RANGE_OFFSET
2821-
== TRAMPOLINE_EHFRAME_FDE_PC_OFFSET + field_size,
2822-
"FDE address_range offset is wrong");
2823-
for (size_t i = 0; i < 2 * field_size; i++) {
2824-
CHECK(data[TRAMPOLINE_EHFRAME_FDE_PC_OFFSET + i] == 0,
2825-
"FDE placeholder fields are not zero");
2826-
}
2827-
/* The FDE's own augmentation data length must follow and be 0. */
2828-
size_t fde_aug_offset = TRAMPOLINE_EHFRAME_FDE_RANGE_OFFSET + field_size;
2829-
CHECK(fde_aug_offset < size, "FDE augmentation data length byte is missing");
2830-
CHECK(data[fde_aug_offset] == 0, "FDE augmentation data length is not 0");
2831-
2832-
#undef CHECK
2833-
Py_RETURN_NONE;
2834-
}
2835-
#endif /* PY_HAVE_PERF_TRAMPOLINE */
2836-
28372721
static PyObject *
28382722
compile_perf_trampoline_entry(PyObject *self, PyObject *args)
28392723
{
@@ -3469,9 +3353,6 @@ static PyMethodDef module_functions[] = {
34693353
{"interpreter_refcount_linked", interpreter_refcount_linked, METH_O},
34703354
{"compile_perf_trampoline_entry", compile_perf_trampoline_entry, METH_VARARGS},
34713355
{"perf_trampoline_set_persist_after_fork", perf_trampoline_set_persist_after_fork, METH_VARARGS},
3472-
#if defined(PY_HAVE_PERF_TRAMPOLINE)
3473-
{"test_trampoline_ehframe", test_trampoline_ehframe, METH_NOARGS},
3474-
#endif
34753356
{"get_crossinterp_data", _PyCFunction_CAST(get_crossinterp_data),
34763357
METH_VARARGS | METH_KEYWORDS},
34773358
{"restore_crossinterp_data", restore_crossinterp_data, METH_VARARGS},

0 commit comments

Comments
 (0)