tr2: make process info collection platform-generic

To pave the way for non-Windows platforms to define trace2_collect_process_info(), reorganize the stub-or-definition schema to something which doesn't directly reference Windows. Platforms which want to collect parent process information in the future should: 1. Add an implementation to compat/ (e.g. compat/somearch/procinfo.c) 2. Add that object to COMPAT_OBJS to config.mak.uname (e.g. COMPAT_OBJS += compat/somearch/procinfo.o) 3. Define HAVE_PLATFORM_PROCINFO in config.mak.uname In the Windows case, this definition lives in compat/win32/trace2_win32_process_info.c, which is already conditionally added to COMPAT_OBJS; so let's add HAVE_PLATFORM_PROCINFO to hint to the build that compat/stub/procinfo.c should not be used. Signed-off-by: Emily Shaffer <emilyshaffer@google.com> Helped-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Emily Shaffer committed Jul 21, 2021 at 18:27 UTC b7e6a4162207785c66a1de6f4530499925b762b6
4 files changed +16 -6
Makefile
+4
@@ -1890,6 +1890,10 @@ ifneq ($(PROCFS_EXECUTABLE_PATH),)
1890 BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(procfs_executable_path_SQ)"'
1891 endif
1892
1893 +ifndef HAVE_PLATFORM_PROCINFO
1894 + COMPAT_OBJS += compat/stub/procinfo.o
1895 +endif
1896 +
1897 ifdef HAVE_NS_GET_EXECUTABLE_PATH
1898 BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH
1899 endif
compat/stub/procinfo.c new
+11
@@ -0,0 +1,11 @@
1 +#include "git-compat-util.h"
2 +
3 +#include "trace2.h"
4 +
5 +/*
6 + * Stub. See sample implementations in compat/linux/procinfo.c and
7 + * compat/win32/trace2_win32_process_info.c.
8 + */
9 +void trace2_collect_process_info(enum trace2_process_info_reason reason)
10 +{
11 +}
config.mak.uname
+1
@@ -612,6 +612,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
612 ETAGS_TARGET = ETAGS
613 NO_POSIX_GOODIES = UnfortunatelyYes
614 DEFAULT_HELP_FORMAT = html
615 + HAVE_PLATFORM_PROCINFO = YesPlease
616 BASIC_LDFLAGS += -municode
617 COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
618 COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
trace2.h
-6
@@ -492,13 +492,7 @@ enum trace2_process_info_reason {
492 TRACE2_PROCESS_INFO_EXIT,
493 };
494
495 -#if defined(GIT_WINDOWS_NATIVE)
495 void trace2_collect_process_info(enum trace2_process_info_reason reason);
497 -#else
498 -#define trace2_collect_process_info(reason) \
499 - do { \
500 - } while (0)
501 -#endif
496
497 const char *trace2_session_id(void);
498