Skip to content

Commit

Permalink
Merge pull request #5745 from BOINC/dpa_debug
Browse files Browse the repository at this point in the history
clarify meaning of DEBUG in C++ code
  • Loading branch information
AenBleidd committed Aug 15, 2024
2 parents e1fa944 + db5f6bb commit d8fe23b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
8 changes: 5 additions & 3 deletions api/ttfont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

// originally adapted by Carl Christensen

//#define TTFONT_DEBUG

#ifdef _WIN32
#include "boinc_win.h"
#endif
Expand Down Expand Up @@ -105,8 +107,8 @@ void ttf_load_fonts(
//g_font[i] = new FTPolygonFont(vpath);
g_font[i] = new FTTextureFont(vpath);
if(!g_font[i]->Error()) {
#ifdef _DEBUG
fprintf(stderr, "Successfully loaded '%s'...\n", vpath);
#ifdef TTFONT_DEBUG
fprintf(stderr, "Successfully loaded '%s'...\n", vpath);
#endif
int iScale = 30;
if (strScaleFont && !strcmp(strScaleFont, g_cstrFont[i])) iScale = iScaleFont;
Expand All @@ -121,7 +123,7 @@ void ttf_load_fonts(
g_iFont = i;

}
#ifdef _DEBUG
#ifdef TTFONT_DEBUG
else {
fprintf(stderr, "Failed to load '%s'...\n", vpath);
}
Expand Down
7 changes: 4 additions & 3 deletions client/check_security.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

// check_security.C

//#define DEBUG_CHECK_SECURITY

#include <sys/types.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -83,7 +84,7 @@ int use_sandbox, int isManager, char* path_to_error, int len
int isMacInstaller = 0;

useFakeProjectUserAndGroup = ! use_sandbox;
#ifdef _DEBUG
#ifdef DEBUG_CHECK_SECURITY
#ifdef DEBUG_WITH_FAKE_PROJECT_USER_AND_GROUP
useFakeProjectUserAndGroup = 1;
#endif
Expand All @@ -107,7 +108,7 @@ int use_sandbox, int isManager, char* path_to_error, int len
return -1099;
}
#endif
#endif // _DEBUG
#endif // DEBUG_CHECK_SECURITY

// GDB can't attach to applications which are running as a different user or group so
// it ignores the S_ISUID and S_ISGID permission bits when launching an application.
Expand Down Expand Up @@ -280,7 +281,7 @@ int use_sandbox, int isManager, char* path_to_error, int len
snprintf(full_path, sizeof(full_path), "/Library/Screen Savers/%s.saver/Contents/Resources/gfx_switcher", saverName[i]);
retval = stat(full_path, &sbuf);
if (! retval) {
#ifdef _DEBUG
#ifdef DEBUG_CHECK_SECURITY
if (sbuf.st_uid != boinc_master_uid)
return -1101;

Expand Down
6 changes: 4 additions & 2 deletions lib/gui_rpc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
using std::string;
using std::vector;

//#define SHOW_MSGS

RPC_CLIENT::RPC_CLIENT() {
sock = -1;
start_time = 0;
Expand Down Expand Up @@ -352,15 +354,15 @@ int RPC::do_rpc(const char* req) {

//fprintf(stderr, "RPC::do_rpc rpc_client->sock = '%d'", rpc_client->sock);
if (rpc_client->sock == -1) return ERR_CONNECT;
#ifdef DEBUG
#ifdef SHOW_MSGS
puts(req);
#endif
retval = rpc_client->send_request(req);
if (retval) return retval;
retval = rpc_client->get_reply(mbuf);
if (retval) return retval;
fin.init_buf_read(mbuf);
#ifdef DEBUG
#ifdef SHOW_MSGS
puts(mbuf);
#endif
return 0;
Expand Down
7 changes: 6 additions & 1 deletion lib/gui_rpc_client_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void APP_VERSION::print() {
}

void WORKUNIT::print() {
printf(" project: %s\n", project->project_name.c_str());
printf(" name: %s\n", name);
printf(" FP estimate: %e\n", rsc_fpops_est);
printf(" FP bound: %e\n", rsc_fpops_bound);
Expand All @@ -151,7 +152,11 @@ void WORKUNIT::print() {
void RESULT::print() {
printf(" name: %s\n", name);
printf(" WU name: %s\n", wu_name);
printf(" project URL: %s\n", project_url);
if (project) {
printf(" project: %s\n", project->project_name.c_str());
} else {
printf(" project URL: %s\n", project_url);
}
time_t foo = (time_t)received_time;
printf(" received: %s", ctime(&foo));
foo = (time_t)report_deadline;
Expand Down
18 changes: 9 additions & 9 deletions lib/proc_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@

using std::vector;

//#define DEBUG
//#define DEBUG_PROC_CONTROL

#ifdef DEBUG
#ifdef DEBUG_PROC_CONTROL
#include <stdio.h>
#endif

Expand All @@ -74,7 +74,7 @@ void get_descendants(int pid, vector<int>& pids) {
retval = procinfo_setup(pm);
if (retval) return;
get_descendants_aux(pm, pid, pids);
#ifdef DEBUG
#ifdef DEBUG_PROC_CONTROL
fprintf(stderr, "descendants of %d:\n", pid);
for (unsigned int i=0; i<pids.size(); i++) {
fprintf(stderr, " %d\n", pids[i]);
Expand Down Expand Up @@ -107,7 +107,7 @@ int suspend_or_resume_threads(
DWORD n;
static vector<DWORD> suspended_threads;

#ifdef DEBUG
#ifdef DEBUG_PROC_CONTROL
fprintf(stderr, "start: check_exempt %d %s\n", check_exempt, precision_time_to_string(dtime()));
fprintf(stderr, "%s processes", resume?"resume":"suspend");
for (unsigned int i=0; i<pids.size(); i++) {
Expand Down Expand Up @@ -135,12 +135,12 @@ int suspend_or_resume_threads(

do {
if (check_exempt && !diagnostics_is_thread_exempt_suspend(te.th32ThreadID)) {
#ifdef DEBUG
#ifdef DEBUG_PROC_CONTROL
fprintf(stderr, "thread is exempt\n");
#endif
continue;
}
#ifdef DEBUG
#ifdef DEBUG_PROC_CONTROL
fprintf(stderr, "thread %d PID %d %s\n",
te.th32ThreadID, te.th32OwnerProcessID,
precision_time_to_string(dtime())
Expand All @@ -157,7 +157,7 @@ int suspend_or_resume_threads(
te.th32ThreadID
) != suspended_threads.end()) {
n = ResumeThread(thread);
#ifdef DEBUG
#ifdef DEBUG_PROC_CONTROL
fprintf(stderr, "ResumeThread returns %d\n", n);
#endif
} else {
Expand All @@ -166,7 +166,7 @@ int suspend_or_resume_threads(
} else {
n = SuspendThread(thread);
suspended_threads.push_back(te.th32ThreadID);
#ifdef DEBUG
#ifdef DEBUG_PROC_CONTROL
fprintf(stderr, "SuspendThread returns %d\n", n);
#endif
}
Expand All @@ -175,7 +175,7 @@ int suspend_or_resume_threads(
} while (Thread32Next(threads, &te));

CloseHandle (threads);
#ifdef DEBUG
#ifdef DEBUG_PROC_CONTROL
fprintf(stderr, "end: %s\n", precision_time_to_string(dtime()));
#endif
return retval;
Expand Down

0 comments on commit d8fe23b

Please sign in to comment.