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

@ -66,9 +66,6 @@ LIBS = $(BLANK_AT_MAKETIME)
if DEBUGBUILD
AM_CPPFLAGS += -DDEBUGBUILD
endif
if CURLDEBUG
AM_CPPFLAGS += -DCURLDEBUG
endif
AM_CPPFLAGS += -DBUILDING_LIBCURL
if DOING_NATIVE_WINDOWS

View file

@ -485,7 +485,7 @@ struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
}
#endif
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
#if defined(CURL_MEMDEBUG) && defined(HAVE_GETADDRINFO) && \
defined(HAVE_FREEADDRINFO)
/*
* curl_dbg_freeaddrinfo()
@ -515,9 +515,9 @@ void curl_dbg_freeaddrinfo(struct addrinfo *freethis,
freeaddrinfo(freethis);
#endif
}
#endif /* CURLDEBUG && HAVE_FREEADDRINFO */
#endif /* CURL_MEMDEBUG && HAVE_FREEADDRINFO */
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO)
#if defined(CURL_MEMDEBUG) && defined(HAVE_GETADDRINFO)
/*
* curl_dbg_getaddrinfo()
*
@ -553,7 +553,7 @@ int curl_dbg_getaddrinfo(const char *hostname,
curl_dbg_log("ADDR %s:%d getaddrinfo() failed\n", source, line);
return res;
}
#endif /* CURLDEBUG && HAVE_GETADDRINFO */
#endif /* CURL_MEMDEBUG && HAVE_GETADDRINFO */
#if defined(HAVE_GETADDRINFO) && defined(USE_RESOLVE_ON_IPS)
/*

View file

@ -79,13 +79,13 @@ struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
bool abstract);
#endif
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
#if defined(CURL_MEMDEBUG) && defined(HAVE_GETADDRINFO) && \
defined(HAVE_FREEADDRINFO)
void curl_dbg_freeaddrinfo(struct addrinfo *freethis, int line,
const char *source);
#endif
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO)
#if defined(CURL_MEMDEBUG) && defined(HAVE_GETADDRINFO)
int curl_dbg_getaddrinfo(const char *hostname, const char *service,
const struct addrinfo *hints,
struct addrinfo **result, int line,

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) && \

View file

@ -45,7 +45,7 @@ int curlx_fseek(void *stream, curl_off_t offset, int whence)
#include "multibyte.h"
#include "timeval.h"
#ifdef CURLDEBUG
#ifdef CURL_MEMDEBUG
/*
* Use system allocators to avoid infinite recursion when called by curl's
* memory tracker memdebug functions.

View file

@ -61,7 +61,7 @@ int curlx_win32_rename(const char *oldpath, const char *newpath);
#define curlx_rename rename
#endif
#ifdef CURLDEBUG
#ifdef CURL_MEMDEBUG
#define curlx_fopen(file, mode) curl_dbg_fopen(file, mode, __LINE__, __FILE__)
#define curlx_freopen(file, mode, fh) \
curl_dbg_freopen(file, mode, fh, __LINE__, __FILE__)

View file

@ -29,8 +29,8 @@
#include <ares.h>
#endif
#if defined(CURLDEBUG) && defined(USE_ARES) && defined(HAVE_GETADDRINFO) && \
(ARES_VERSION >= 0x011a00) /* >= 1.26.0 */
#if defined(CURL_MEMDEBUG) && defined(HAVE_GETADDRINFO) && \
defined(USE_ARES) && (ARES_VERSION >= 0x011a00) /* >= 1.26.0 */
#define USE_FAKE_GETADDRINFO 1
#endif

View file

@ -32,7 +32,7 @@ VS_VERSION_INFO VERSIONINFO
FILEVERSION RC_VERSION
PRODUCTVERSION RC_VERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#if defined(DEBUGBUILD) || defined(UNITTESTS) || defined(CURLDEBUG) || defined(_DEBUG)
#if defined(DEBUGBUILD) || defined(UNITTESTS) || defined(_DEBUG)
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0L

View file

@ -23,7 +23,7 @@
***************************************************************************/
#include "curl_setup.h"
#ifdef CURLDEBUG
#ifdef CURL_MEMDEBUG
#include <stddef.h> /* for offsetof() */
@ -575,4 +575,4 @@ void curl_dbg_log(const char *format, ...)
curl_dbg_unlock(was_locked);
}
#endif /* CURLDEBUG */
#endif /* CURL_MEMDEBUG */

View file

@ -541,9 +541,6 @@ static const struct feat features_table[] = {
#ifdef USE_TLS_SRP
FEATURE("TLS-SRP", NULL, CURL_VERSION_TLSAUTH_SRP),
#endif
#ifdef CURLDEBUG
FEATURE("TrackMemory", NULL, CURL_VERSION_CURLDEBUG),
#endif
#if defined(_WIN32) && defined(UNICODE) && defined(_UNICODE)
FEATURE("Unicode", NULL, CURL_VERSION_UNICODE),
#endif
@ -690,6 +687,10 @@ curl_version_info_data *curl_version_info(CURLversion stamp)
feature_names[n++] = p->name;
}
#ifdef DEBUGBUILD
features |= CURL_VERSION_CURLDEBUG; /* for compatibility */
#endif
feature_names[n] = NULL; /* Terminate array. */
version_info.features = features;