mirror of
https://github.com/python/cpython.git
synced 2025-09-18 22:50:26 +00:00
bpo-35064 prefix smelly symbols that appear with COUNT_ALLOCS with _Py_ (GH-10152)
Configuring python with ./configure --with-pydebug CFLAGS="-D COUNT_ALLOCS -O0" makes "make smelly" fail as some symbols were being exported without the "Py_" or "_Py" prefixes.
This commit is contained in:
parent
6015cc50bc
commit
49c75a8086
7 changed files with 31 additions and 31 deletions
|
@ -752,10 +752,10 @@ PyAPI_FUNC(void) _PyDebug_PrintTotalRefs(void);
|
||||||
#endif /* Py_REF_DEBUG */
|
#endif /* Py_REF_DEBUG */
|
||||||
|
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
PyAPI_FUNC(void) inc_count(PyTypeObject *);
|
PyAPI_FUNC(void) _Py_inc_count(PyTypeObject *);
|
||||||
PyAPI_FUNC(void) dec_count(PyTypeObject *);
|
PyAPI_FUNC(void) _Py_dec_count(PyTypeObject *);
|
||||||
#define _Py_INC_TPALLOCS(OP) inc_count(Py_TYPE(OP))
|
#define _Py_INC_TPALLOCS(OP) _Py_inc_count(Py_TYPE(OP))
|
||||||
#define _Py_INC_TPFREES(OP) dec_count(Py_TYPE(OP))
|
#define _Py_INC_TPFREES(OP) _Py_dec_count(Py_TYPE(OP))
|
||||||
#define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees--
|
#define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees--
|
||||||
#define _Py_COUNT_ALLOCS_COMMA ,
|
#define _Py_COUNT_ALLOCS_COMMA ,
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -18,7 +18,7 @@ class bytes "PyBytesObject *" "&PyBytes_Type"
|
||||||
#include "clinic/bytesobject.c.h"
|
#include "clinic/bytesobject.c.h"
|
||||||
|
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
Py_ssize_t null_strings, one_strings;
|
Py_ssize_t _Py_null_strings, _Py_one_strings;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static PyBytesObject *characters[UCHAR_MAX + 1];
|
static PyBytesObject *characters[UCHAR_MAX + 1];
|
||||||
|
@ -66,7 +66,7 @@ _PyBytes_FromSize(Py_ssize_t size, int use_calloc)
|
||||||
|
|
||||||
if (size == 0 && (op = nullstring) != NULL) {
|
if (size == 0 && (op = nullstring) != NULL) {
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
null_strings++;
|
_Py_null_strings++;
|
||||||
#endif
|
#endif
|
||||||
Py_INCREF(op);
|
Py_INCREF(op);
|
||||||
return (PyObject *)op;
|
return (PyObject *)op;
|
||||||
|
@ -110,7 +110,7 @@ PyBytes_FromStringAndSize(const char *str, Py_ssize_t size)
|
||||||
(op = characters[*str & UCHAR_MAX]) != NULL)
|
(op = characters[*str & UCHAR_MAX]) != NULL)
|
||||||
{
|
{
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
one_strings++;
|
_Py_one_strings++;
|
||||||
#endif
|
#endif
|
||||||
Py_INCREF(op);
|
Py_INCREF(op);
|
||||||
return (PyObject *)op;
|
return (PyObject *)op;
|
||||||
|
@ -146,14 +146,14 @@ PyBytes_FromString(const char *str)
|
||||||
}
|
}
|
||||||
if (size == 0 && (op = nullstring) != NULL) {
|
if (size == 0 && (op = nullstring) != NULL) {
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
null_strings++;
|
_Py_null_strings++;
|
||||||
#endif
|
#endif
|
||||||
Py_INCREF(op);
|
Py_INCREF(op);
|
||||||
return (PyObject *)op;
|
return (PyObject *)op;
|
||||||
}
|
}
|
||||||
if (size == 1 && (op = characters[*str & UCHAR_MAX]) != NULL) {
|
if (size == 1 && (op = characters[*str & UCHAR_MAX]) != NULL) {
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
one_strings++;
|
_Py_one_strings++;
|
||||||
#endif
|
#endif
|
||||||
Py_INCREF(op);
|
Py_INCREF(op);
|
||||||
return (PyObject *)op;
|
return (PyObject *)op;
|
||||||
|
|
|
@ -42,7 +42,7 @@ PyObject *_PyLong_One = NULL;
|
||||||
*/
|
*/
|
||||||
static PyLongObject small_ints[NSMALLNEGINTS + NSMALLPOSINTS];
|
static PyLongObject small_ints[NSMALLNEGINTS + NSMALLPOSINTS];
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
Py_ssize_t quick_int_allocs, quick_neg_int_allocs;
|
Py_ssize_t _Py_quick_int_allocs, _Py_quick_neg_int_allocs;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -54,9 +54,9 @@ get_small_int(sdigit ival)
|
||||||
Py_INCREF(v);
|
Py_INCREF(v);
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
if (ival >= 0)
|
if (ival >= 0)
|
||||||
quick_int_allocs++;
|
_Py_quick_int_allocs++;
|
||||||
else
|
else
|
||||||
quick_neg_int_allocs++;
|
_Py_quick_neg_int_allocs++;
|
||||||
#endif
|
#endif
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,11 +93,11 @@ static PyTypeObject *type_list;
|
||||||
is set, they will be removed from the type_list
|
is set, they will be removed from the type_list
|
||||||
once the last object is deallocated. */
|
once the last object is deallocated. */
|
||||||
static int unlist_types_without_objects;
|
static int unlist_types_without_objects;
|
||||||
extern Py_ssize_t tuple_zero_allocs, fast_tuple_allocs;
|
extern Py_ssize_t _Py_tuple_zero_allocs, _Py_fast_tuple_allocs;
|
||||||
extern Py_ssize_t quick_int_allocs, quick_neg_int_allocs;
|
extern Py_ssize_t _Py_quick_int_allocs, _Py_quick_neg_int_allocs;
|
||||||
extern Py_ssize_t null_strings, one_strings;
|
extern Py_ssize_t _Py_null_strings, _Py_one_strings;
|
||||||
void
|
void
|
||||||
dump_counts(FILE* f)
|
_Py_dump_counts(FILE* f)
|
||||||
{
|
{
|
||||||
PyInterpreterState *interp = _PyInterpreterState_Get();
|
PyInterpreterState *interp = _PyInterpreterState_Get();
|
||||||
if (!interp->core_config.show_alloc_count) {
|
if (!interp->core_config.show_alloc_count) {
|
||||||
|
@ -113,17 +113,17 @@ dump_counts(FILE* f)
|
||||||
tp->tp_maxalloc);
|
tp->tp_maxalloc);
|
||||||
fprintf(f, "fast tuple allocs: %" PY_FORMAT_SIZE_T "d, "
|
fprintf(f, "fast tuple allocs: %" PY_FORMAT_SIZE_T "d, "
|
||||||
"empty: %" PY_FORMAT_SIZE_T "d\n",
|
"empty: %" PY_FORMAT_SIZE_T "d\n",
|
||||||
fast_tuple_allocs, tuple_zero_allocs);
|
_Py_fast_tuple_allocs, _Py_tuple_zero_allocs);
|
||||||
fprintf(f, "fast int allocs: pos: %" PY_FORMAT_SIZE_T "d, "
|
fprintf(f, "fast int allocs: pos: %" PY_FORMAT_SIZE_T "d, "
|
||||||
"neg: %" PY_FORMAT_SIZE_T "d\n",
|
"neg: %" PY_FORMAT_SIZE_T "d\n",
|
||||||
quick_int_allocs, quick_neg_int_allocs);
|
_Py_quick_int_allocs, _Py_quick_neg_int_allocs);
|
||||||
fprintf(f, "null strings: %" PY_FORMAT_SIZE_T "d, "
|
fprintf(f, "null strings: %" PY_FORMAT_SIZE_T "d, "
|
||||||
"1-strings: %" PY_FORMAT_SIZE_T "d\n",
|
"1-strings: %" PY_FORMAT_SIZE_T "d\n",
|
||||||
null_strings, one_strings);
|
_Py_null_strings, _Py_one_strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
get_counts(void)
|
_Py_get_counts(void)
|
||||||
{
|
{
|
||||||
PyTypeObject *tp;
|
PyTypeObject *tp;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
|
@ -150,12 +150,12 @@ get_counts(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
inc_count(PyTypeObject *tp)
|
_Py_inc_count(PyTypeObject *tp)
|
||||||
{
|
{
|
||||||
if (tp->tp_next == NULL && tp->tp_prev == NULL) {
|
if (tp->tp_next == NULL && tp->tp_prev == NULL) {
|
||||||
/* first time; insert in linked list */
|
/* first time; insert in linked list */
|
||||||
if (tp->tp_next != NULL) /* sanity check */
|
if (tp->tp_next != NULL) /* sanity check */
|
||||||
Py_FatalError("XXX inc_count sanity check");
|
Py_FatalError("XXX _Py_inc_count sanity check");
|
||||||
if (type_list)
|
if (type_list)
|
||||||
type_list->tp_prev = tp;
|
type_list->tp_prev = tp;
|
||||||
tp->tp_next = type_list;
|
tp->tp_next = type_list;
|
||||||
|
@ -181,7 +181,7 @@ inc_count(PyTypeObject *tp)
|
||||||
tp->tp_maxalloc = tp->tp_allocs - tp->tp_frees;
|
tp->tp_maxalloc = tp->tp_allocs - tp->tp_frees;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dec_count(PyTypeObject *tp)
|
void _Py_dec_count(PyTypeObject *tp)
|
||||||
{
|
{
|
||||||
tp->tp_frees++;
|
tp->tp_frees++;
|
||||||
if (unlist_types_without_objects &&
|
if (unlist_types_without_objects &&
|
||||||
|
|
|
@ -28,8 +28,8 @@ static PyTupleObject *free_list[PyTuple_MAXSAVESIZE];
|
||||||
static int numfree[PyTuple_MAXSAVESIZE];
|
static int numfree[PyTuple_MAXSAVESIZE];
|
||||||
#endif
|
#endif
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
Py_ssize_t fast_tuple_allocs;
|
Py_ssize_t _Py_fast_tuple_allocs;
|
||||||
Py_ssize_t tuple_zero_allocs;
|
Py_ssize_t _Py_tuple_zero_allocs;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Debug statistic to count GC tracking of tuples.
|
/* Debug statistic to count GC tracking of tuples.
|
||||||
|
@ -89,7 +89,7 @@ PyTuple_New(Py_ssize_t size)
|
||||||
op = free_list[0];
|
op = free_list[0];
|
||||||
Py_INCREF(op);
|
Py_INCREF(op);
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
tuple_zero_allocs++;
|
_Py_tuple_zero_allocs++;
|
||||||
#endif
|
#endif
|
||||||
return (PyObject *) op;
|
return (PyObject *) op;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ PyTuple_New(Py_ssize_t size)
|
||||||
free_list[size] = (PyTupleObject *) op->ob_item[0];
|
free_list[size] = (PyTupleObject *) op->ob_item[0];
|
||||||
numfree[size]--;
|
numfree[size]--;
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
fast_tuple_allocs++;
|
_Py_fast_tuple_allocs++;
|
||||||
#endif
|
#endif
|
||||||
/* Inline PyObject_InitVar */
|
/* Inline PyObject_InitVar */
|
||||||
#ifdef Py_TRACE_REFS
|
#ifdef Py_TRACE_REFS
|
||||||
|
|
|
@ -929,7 +929,7 @@ Py_Initialize(void)
|
||||||
|
|
||||||
|
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
extern void dump_counts(FILE*);
|
extern void _Py_dump_counts(FILE*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Flush stdout and stderr */
|
/* Flush stdout and stderr */
|
||||||
|
@ -1112,7 +1112,7 @@ Py_FinalizeEx(void)
|
||||||
|
|
||||||
/* Debugging stuff */
|
/* Debugging stuff */
|
||||||
#ifdef COUNT_ALLOCS
|
#ifdef COUNT_ALLOCS
|
||||||
dump_counts(stderr);
|
_Py_dump_counts(stderr);
|
||||||
#endif
|
#endif
|
||||||
/* dump hash stats */
|
/* dump hash stats */
|
||||||
_PyHash_Fini();
|
_PyHash_Fini();
|
||||||
|
|
|
@ -1340,9 +1340,9 @@ size."
|
||||||
static PyObject *
|
static PyObject *
|
||||||
sys_getcounts(PyObject *self)
|
sys_getcounts(PyObject *self)
|
||||||
{
|
{
|
||||||
extern PyObject *get_counts(void);
|
extern PyObject *_Py_get_counts(void);
|
||||||
|
|
||||||
return get_counts();
|
return _Py_get_counts();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue