Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: untangle CURLDEBUG and DEBUGBUILD macros #13718

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:
- { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '!19 !1233', config: '--enable-debug --disable-threaded-resolver --disable-proxy' }
- { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '!19 !504 !704 !705 !1233', config: '--enable-debug --disable-threaded-resolver' }
- { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '!19 !504 !704 !705 !1233', config: '' }
- { build: 'autotools', sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --disable-threaded-resolver --enable-static=no' }
- { build: 'autotools', sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --disable-threaded-resolver --disable-curldebug --enable-static=no' }
# FIXME: WebSockets test results ignored due to frequent failures on native Windows:
- { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: '!TFTP ~2301 ~2302' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON', type: 'Debug' }
- { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_CURLDEBUG=ON', type: 'Release' }
Expand Down
7 changes: 4 additions & 3 deletions CMake/CurlSymbolHiding.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ include(CheckCSourceCompiles)
option(CURL_HIDDEN_SYMBOLS "Set to ON to hide libcurl internal symbols (=hide all symbols that aren't officially external)." ON)
mark_as_advanced(CURL_HIDDEN_SYMBOLS)

if(WIN32 AND ENABLE_CURLDEBUG)
# We need to export internal debug functions (e.g. curl_dbg_*), so disable
# symbol hiding for debug builds.
if(WIN32 AND (ENABLE_DEBUG OR ENABLE_CURLDEBUG))
# We need to export internal debug functions,
# e.g. curl_easy_perform_ev() or curl_dbg_*(),
# so disable symbol hiding for debug builds and for memory tracking.
set(CURL_HIDDEN_SYMBOLS OFF)
endif()

Expand Down
11 changes: 11 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ environment:
SCHANNEL: 'ON'
ENABLE_UNICODE: 'ON'
HTTP_ONLY: 'OFF'
- job_name: 'CMake, VS2022, Release, x64, Schannel, Shared, Unicode, DEBUGBULID, no-CURLDEBUG, Build-only'
APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022'
BUILD_SYSTEM: CMake
PRJ_GEN: 'Visual Studio 17 2022'
TARGET: '-A x64'
PRJ_CFG: Release
SCHANNEL: 'ON'
ENABLE_UNICODE: 'ON'
HTTP_ONLY: 'OFF'
SHARED: 'ON'
CURLDEBUG: 'OFF'
- job_name: 'CMake, VS2022, Debug, x64, no SSL, Static, Build-only'
APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022'
BUILD_SYSTEM: CMake
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ AM_MAINTAINER_MODE
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

CURL_CHECK_OPTION_DEBUG
AM_CONDITIONAL(DEBUGBUILD, test x$want_debug = xyes)
CURL_CHECK_OPTION_OPTIMIZE
CURL_CHECK_OPTION_WARNINGS
CURL_CHECK_OPTION_WERROR
Expand Down Expand Up @@ -549,7 +550,6 @@ CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH
CURL_CHECK_COMPILER_SYMBOL_HIDING

CURL_CHECK_CURLDEBUG
AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes)

supports_unittests=yes
# cross-compilation of unit tests static library/programs fails when
Expand Down
2 changes: 1 addition & 1 deletion include/curl/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CS_ = $(CS_0)
checksrc:
$(CHECKSRC)@PERL@ $(top_srcdir)/scripts/checksrc.pl -D$(top_srcdir)/include/curl $(pkginclude_HEADERS)

if CURLDEBUG
if DEBUGBUILD
# for debug builds, we scan the sources on all regular make invokes
all-local: checksrc
endif
2 changes: 1 addition & 1 deletion lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ checksrc:
-W$(srcdir)/curl_config.h $(srcdir)/*.[ch] $(srcdir)/vauth/*.[ch] \
$(srcdir)/vtls/*.[ch] $(srcdir)/vquic/*.[ch] $(srcdir)/vssh/*.[ch])

if CURLDEBUG
if DEBUGBUILD
# for debug builds, we scan the sources on all regular make invokes
all-local: checksrc
endif
Expand Down
2 changes: 1 addition & 1 deletion lib/cfilters.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ CURLcode Curl_conn_send(struct Curl_easy *data, int sockindex,
DEBUGASSERT(data);
DEBUGASSERT(data->conn);
conn = data->conn;
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
{
/* Allow debug builds to override this logic to force short sends
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/conncache.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct conncache {
#define BUNDLE_UNKNOWN 0 /* initial value */
#define BUNDLE_MULTIPLEX 2

#ifdef CURLDEBUG
#ifdef DEBUGBUILD
/* the debug versions of these macros make extra certain that the lock is
never doubly locked or unlocked */
#define CONNCACHE_LOCK(x) \
Expand Down
14 changes: 7 additions & 7 deletions lib/doh.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ doh_write_cb(const void *contents, size_t size, size_t nmemb, void *userp)
return realsize;
}

#if defined(USE_HTTPSRR) && defined(CURLDEBUG)
#if defined(USE_HTTPSRR) && defined(DEBUGBUILD)
static void local_print_buf(struct Curl_easy *data,
const char *prefix,
unsigned char *buf, size_t len)
Expand Down Expand Up @@ -285,7 +285,7 @@ static CURLcode dohprobe(struct Curl_easy *data,
ERROR_CHECK_SETOPT(CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
ERROR_CHECK_SETOPT(CURLOPT_PIPEWAIT, 1L);
#endif
#ifndef CURLDEBUG
#ifndef DEBUGBUILD
/* enforce HTTPS if not debug */
ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
#else
Expand Down Expand Up @@ -870,7 +870,7 @@ static void showdoh(struct Curl_easy *data,
}
#ifdef USE_HTTPSRR
for(i = 0; i < d->numhttps_rrs; i++) {
# ifdef CURLDEBUG
# ifdef DEBUGBUILD
local_print_buf(data, "DoH HTTPS",
d->https_rrs[i].val, d->https_rrs[i].len);
# else
Expand Down Expand Up @@ -1143,7 +1143,7 @@ static CURLcode local_decode_rdata_alpn(unsigned char *rrval, size_t len,
return CURLE_BAD_CONTENT_ENCODING;
}

#ifdef CURLDEBUG
#ifdef DEBUGBUILD
static CURLcode test_alpn_escapes(void)
{
/* we'll use an example from draft-ietf-dnsop-svcb, figure 10 */
Expand Down Expand Up @@ -1176,7 +1176,7 @@ static CURLcode Curl_doh_decode_httpsrr(unsigned char *rrval, size_t len,
struct Curl_https_rrinfo *lhrr = NULL;
char *dnsname = NULL;

#ifdef CURLDEBUG
#ifdef DEBUGBUILD
/* a few tests of escaping, shouldn't be here but ok for now */
if(test_alpn_escapes() != CURLE_OK)
return CURLE_OUT_OF_MEMORY;
Expand Down Expand Up @@ -1244,7 +1244,7 @@ static CURLcode Curl_doh_decode_httpsrr(unsigned char *rrval, size_t len,
return CURLE_OUT_OF_MEMORY;
}

# ifdef CURLDEBUG
# ifdef DEBUGBUILD
static void local_print_httpsrr(struct Curl_easy *data,
struct Curl_https_rrinfo *hrr)
{
Expand Down Expand Up @@ -1382,7 +1382,7 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data,
return result;
}
infof(data, "Some HTTPS RR to process");
# ifdef CURLDEBUG
# ifdef DEBUGBUILD
local_print_httpsrr(data, hrr);
# endif
(*dnsp)->hinfo = hrr;
Expand Down
6 changes: 3 additions & 3 deletions lib/easy.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ struct Curl_easy *curl_easy_init(void)
return data;
}

#ifdef CURLDEBUG
#ifdef DEBUGBUILD

struct socketmonitor {
struct socketmonitor *next; /* the next node in the list or NULL */
Expand Down Expand Up @@ -655,7 +655,7 @@ static CURLcode easy_events(struct Curl_multi *multi)

return wait_or_timeout(multi, &evs);
}
#else /* CURLDEBUG */
#else /* DEBUGBUILD */
/* when not built with debug, this function doesn't exist */
#define easy_events(x) CURLE_NOT_BUILT_IN
#endif
Expand Down Expand Up @@ -788,7 +788,7 @@ CURLcode curl_easy_perform(struct Curl_easy *data)
return easy_perform(data, FALSE);
}

#ifdef CURLDEBUG
#ifdef DEBUGBUILD
/*
* curl_easy_perform_ev() is the external interface that performs a blocking
* transfer using the event-based API internally.
Expand Down
2 changes: 1 addition & 1 deletion lib/easyif.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CURLcode Curl_senddata(struct Curl_easy *data, const void *buffer,
CURLcode Curl_connect_only_attach(struct Curl_easy *data);
#endif

#ifdef CURLDEBUG
#ifdef DEBUGBUILD
CURL_EXTERN CURLcode curl_easy_perform_ev(struct Curl_easy *easy);
#endif

Expand Down
4 changes: 2 additions & 2 deletions lib/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -2849,7 +2849,7 @@ CURLcode Curl_http_header(struct Curl_easy *data,
#ifndef CURL_DISABLE_ALTSVC
v = (data->asi &&
((data->conn->handler->flags & PROTOPT_SSL) ||
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
/* allow debug builds to circumvent the HTTPS restriction */
getenv("CURL_ALTSVC_HTTP")
#else
Expand Down Expand Up @@ -3116,7 +3116,7 @@ CURLcode Curl_http_header(struct Curl_easy *data,
/* If enabled, the header is incoming and this is over HTTPS */
v = (data->hsts &&
((conn->handler->flags & PROTOPT_SSL) ||
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
/* allow debug builds to circumvent the HTTPS restriction */
getenv("CURL_HSTS_HTTP")
#else
Expand Down
4 changes: 2 additions & 2 deletions lib/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ static size_t mqtt_decode_len(unsigned char *buf,
return len;
}

#ifdef CURLDEBUG
#ifdef DEBUGBUILD
static const char *statenames[]={
"MQTT_FIRST",
"MQTT_REMAINING_LENGTH",
Expand All @@ -606,7 +606,7 @@ static void mqstate(struct Curl_easy *data,
{
struct connectdata *conn = data->conn;
struct mqtt_conn *mqtt = &conn->proto.mqtt;
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
infof(data, "%s (from %s) (next is %s)",
statenames[state],
statenames[mqtt->state],
Expand Down
2 changes: 1 addition & 1 deletion lib/rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static CURLcode randit(struct Curl_easy *data, unsigned int *rnd)
static unsigned int randseed;
static bool seeded = FALSE;

#ifdef CURLDEBUG
#ifdef DEBUGBUILD
char *force_entropy = getenv("CURL_ENTROPY");
if(force_entropy) {
if(!seeded) {
Expand Down
2 changes: 1 addition & 1 deletion lib/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static CURLcode xfer_send(struct Curl_easy *data,
CURLcode result = CURLE_OK;

*pnwritten = 0;
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
{
/* Allow debug builds to override this logic to force short initial
sends
Expand Down
2 changes: 1 addition & 1 deletion lib/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -3028,7 +3028,7 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data,
#ifndef CURL_DISABLE_ALTSVC
if(data->asi && !host && (port == -1) &&
((conn->handler->protocol == CURLPROTO_HTTPS) ||
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
/* allow debug builds to circumvent the HTTPS restriction */
getenv("CURL_ALTSVC_HTTP")
#else
Expand Down
2 changes: 1 addition & 1 deletion lib/urldata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ struct UrlState {
unsigned char select_bits; /* != 0 -> bitmask of socket events for this
transfer overriding anything the socket may
report */
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
BIT(conncache_lock);
#endif
/* when curl_easy_perform() is called, the multi handle is "owned" by
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ checksrc:
$(CHECKSRC)(@PERL@ $(top_srcdir)/scripts/checksrc.pl -D$(srcdir) \
-W$(srcdir)/tool_hugehelp.c $(srcdir)/*.[ch])

if CURLDEBUG
if DEBUGBUILD
# for debug builds, we scan the sources on all regular make invokes
all-local: checksrc
endif
Expand Down
2 changes: 1 addition & 1 deletion src/tool_cfgable.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ struct GlobalConfig {
bool styled_output; /* enable fancy output style detection */
long ms_per_transfer; /* start next transfer after (at least) this
many milliseconds */
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
bool test_event_based;
#endif
bool parallel;
Expand Down
2 changes: 1 addition & 1 deletion src/tool_getparam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
config->sasl_ir = toggle;
break;
case C_TEST_EVENT: /* --test-event */
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
global->test_event_based = toggle;
#else
warnf(global, "--test-event is ignored unless a debug build");
Expand Down
16 changes: 7 additions & 9 deletions src/tool_operate.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,12 @@
#include "tool_progress.h"
#include "tool_ipfs.h"
#include "dynbuf.h"
#ifdef DEBUGBUILD
#include "easyif.h" /* for libcurl's debug-only curl_easy_perform_ev() */
#endif

#include "memdebug.h" /* keep this as LAST include */

#ifdef CURLDEBUG
/* libcurl's debug builds provide an extra function */
CURLcode curl_easy_perform_ev(CURL *easy);
#endif

#ifndef O_BINARY
/* since O_BINARY as used in bitmasks, setting it to zero makes it usable in
source code but yet it doesn't ruin anything */
Expand Down Expand Up @@ -1315,7 +1313,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
my_setopt(curl, CURLOPT_SEEKFUNCTION, tool_seek_cb);

{
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
char *env = getenv("CURL_BUFFERSIZE");
if(env) {
long size = strtol(env, NULL, 10);
Expand Down Expand Up @@ -1647,7 +1645,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
* must do the same thing as classic:
* --cert <filename>:<password> --cert-type p12
* but is designed to test blob */
#if defined(CURLDEBUG) || defined(DEBUGBUILD)
#ifdef DEBUGBUILD
if(config->cert && (strlen(config->cert) > 8) &&
(memcmp(config->cert, "loadmem=",8) == 0)) {
FILE *fInCert = fopen(config->cert + 8, "rb");
Expand Down Expand Up @@ -1690,7 +1688,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
config->proxy_cert_type);


#if defined(CURLDEBUG) || defined(DEBUGBUILD)
#ifdef DEBUGBUILD
if(config->key && (strlen(config->key) > 8) &&
(memcmp(config->key, "loadmem=",8) == 0)) {
FILE *fInCert = fopen(config->key + 8, "rb");
Expand Down Expand Up @@ -2484,7 +2482,7 @@ static CURLcode serial_transfers(struct GlobalConfig *global,
break;
}
start = tvnow();
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
if(global->test_event_based)
result = curl_easy_perform_ev(per->curl);
else
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ checksrc:
(cd server && $(MAKE) checksrc)
(cd http && $(MAKE) checksrc)

if CURLDEBUG
if DEBUGBUILD
# for debug builds, we scan the sources on all regular make invokes
all-local: checksrc
endif
2 changes: 1 addition & 1 deletion tests/libtest/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ CS_ = $(CS_0)
checksrc:
$(CHECKSRC)@PERL@ $(top_srcdir)/scripts/checksrc.pl -D$(srcdir) $(srcdir)/*.[ch]

if CURLDEBUG
if DEBUGBUILD
# for debug builds, we scan the sources on all regular make invokes
all-local: checksrc
endif
2 changes: 1 addition & 1 deletion tests/server/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CS_ = $(CS_0)
checksrc:
$(CHECKSRC)@PERL@ $(top_srcdir)/scripts/checksrc.pl $(srcdir)/*.[ch]

if CURLDEBUG
if DEBUGBUILD
# for debug builds, we scan the sources on all regular make invokes
all-local: checksrc
endif
Loading