build: merge TrackMemory (CURLDEBUG) into debug-enabled option

Drop separate `TrackMemory` (aka `CURLDEBUG`) debug feature.

After recent changes (thread-safety,
193cb00ce9, and updates leading up to
it), `TrackMemory` is unlikely to cause build or runtime issues.

To simplify builds and debug options, enable `TrackMemory`
unconditionally for debug-enabled (aka `DEBUGBUILD`) builds. Before
this patch, this was already the default, with an option to disable
it, or enable it in non-debug-enabled builds.

Note, in practice these two debug options already went hand in hand. It
was not possible to toggle them separately for a long time due to bugs,
before 59dc9f7e69 (2024-05-28) fixed it.

This patch also removes/deprecates separate knobs and feature flags for
`TrackMemory`:
- autotools: `--enable-curldebug`/`--disable-curldebug`
- cmake: `-DENABLE_CURLDEBUG=ON`/`OFF`
- C macro: `CURLDEBUG`
- libcurl: `CURL_VERSION_CURLDEBUG` symbol deprecated in favor
  of `CURL_VERSION_DEBUG`. They always return the same value after this
  patch.

Also:
- drop `TrackMemory` from `curl -V` output.
- rename internal `CURLDEBUG` macro to `CURL_MEMDEBUG` internally.
  To avoid confusion with `DEBUGBUILD`, but to keep guarding
  `TrackMemory`-related internals for readability.
- runtests: bind `TrackMemory` to debug feature. Keep it a separate
  test feature requirement, for clarity.
- CI: drop test builds for combinations of the two options.
- GHA/linux: no longer disable TrackMemory in the TSAN job.

Ref: https://github.com/curl/curl/pull/20328#issuecomment-3754528407

Closes #20331
This commit is contained in:
Viktor Szakats 2026-01-15 14:04:05 +01:00
parent 0002184015
commit 2d5a063121
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
35 changed files with 58 additions and 146 deletions

View file

@ -953,7 +953,11 @@ extern curl_calloc_callback Curl_ccalloc;
#include <curl/curl.h> /* for CURL_EXTERN, curl_socket_t, mprintf.h */
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
#define CURL_MEMDEBUG
#endif
#ifdef CURL_MEMDEBUG
#ifdef __clang__
# define ALLOC_FUNC __attribute__((__malloc__))
# if __clang_major__ >= 4
@ -1049,7 +1053,7 @@ CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode,
curl_dbg_accept4(sock, addr, len, flags, __LINE__, __FILE__)
#endif
#else /* !CURLDEBUG */
#else /* !CURL_MEMDEBUG */
#define sclose(x) CURL_SCLOSE(x)
#define fake_sclose(x) Curl_nop_stmt
@ -1065,11 +1069,11 @@ CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode,
#define CURL_ACCEPT4 accept4
#endif
#endif /* CURLDEBUG */
#endif /* CURL_MEMDEBUG */
/* Allocator macros */
#ifdef CURLDEBUG
#ifdef CURL_MEMDEBUG
#define curlx_strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
#define curlx_malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__)
@ -1087,7 +1091,7 @@ CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode,
#endif
#endif /* _WIN32 */
#else /* !CURLDEBUG */
#else /* !CURL_MEMDEBUG */
#ifdef BUILDING_LIBCURL
#define curlx_strdup(ptr) Curl_cstrdup(ptr)
@ -1115,7 +1119,7 @@ CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode,
#endif
#endif /* _WIN32 */
#endif /* CURLDEBUG */
#endif /* CURL_MEMDEBUG */
/* Some versions of the Android NDK is missing the declaration */
#if defined(HAVE_GETPWUID_R) && \