Skip to content

Commit

Permalink
Meta: Remove unused debug flags, add missing GENERATE_DEBUG
Browse files Browse the repository at this point in the history
Commands that were helpful while investigating this:
```
grep -P '^set' Meta/CMake/all_the_debug_macros.cmake \
  | sed -Ee 's,set\((.+) ON\)$,\1,' > macros.lst
for i in $(cat macros.lst); do
  echo -n "$i "; git grep -Pn '\b'"$i"'\b' | wc -l
done | tee matches.lst
sort -k2 -n matches.lst
```
  • Loading branch information
BenWiederhake authored and ADKaster committed May 14, 2023
1 parent c56481e commit 173f872
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 106 deletions.
40 changes: 0 additions & 40 deletions AK/Debug.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@
# cmakedefine01 CRYPTO_DEBUG
#endif

#ifndef CSOCKET_DEBUG
# cmakedefine01 CSOCKET_DEBUG
#endif

#ifndef CSS_LOADER_DEBUG
# cmakedefine01 CSS_LOADER_DEBUG
#endif
Expand All @@ -74,18 +70,10 @@
# cmakedefine01 CSS_TOKENIZER_DEBUG
#endif

#ifndef CURSOR_TOOL_DEBUG
# cmakedefine01 CURSOR_TOOL_DEBUG
#endif

#ifndef DDS_DEBUG
# cmakedefine01 DDS_DEBUG
#endif

#ifndef DEFERRED_INVOKE_DEBUG
# cmakedefine01 DEFERRED_INVOKE_DEBUG
#endif

#ifndef DHCPV4_DEBUG
# cmakedefine01 DHCPV4_DEBUG
#endif
Expand Down Expand Up @@ -138,10 +126,6 @@
# cmakedefine01 EVENT_DEBUG
#endif

#ifndef EVENTLOOP_DEBUG
# cmakedefine01 EVENTLOOP_DEBUG
#endif

#ifndef FILE_CONTENT_DEBUG
# cmakedefine01 FILE_CONTENT_DEBUG
#endif
Expand All @@ -158,10 +142,6 @@
# cmakedefine01 GEMINI_DEBUG
#endif

#ifndef GEMINIJOB_DEBUG
# cmakedefine01 GEMINIJOB_DEBUG
#endif

#ifndef GENERATE_DEBUG
# cmakedefine01 GENERATE_DEBUG
#endif
Expand All @@ -186,10 +166,6 @@
# cmakedefine01 GPT_DEBUG
#endif

#ifndef GZIP_DEBUG
# cmakedefine01 GZIP_DEBUG
#endif

#ifndef HEAP_DEBUG
# cmakedefine01 HEAP_DEBUG
#endif
Expand All @@ -214,10 +190,6 @@
# cmakedefine01 HTTPJOB_DEBUG
#endif

#ifndef HTTPSJOB_DEBUG
# cmakedefine01 HTTPSJOB_DEBUG
#endif

#ifndef HUNKS_DEBUG
# cmakedefine01 HUNKS_DEBUG
#endif
Expand Down Expand Up @@ -310,14 +282,6 @@
# cmakedefine01 MENU_DEBUG
#endif

#ifndef MENUS_DEBUG
# cmakedefine01 MENUS_DEBUG
#endif

#ifndef MINIMIZE_ANIMATION_DEBUG
# cmakedefine01 MINIMIZE_ANIMATION_DEBUG
#endif

#ifndef MOVE_DEBUG
# cmakedefine01 MOVE_DEBUG
#endif
Expand Down Expand Up @@ -394,10 +358,6 @@
# cmakedefine01 RSA_PARSE_DEBUG
#endif

#ifndef SAFE_SYSCALL_DEBUG
# cmakedefine01 SAFE_SYSCALL_DEBUG
#endif

#ifndef SERVICE_DEBUG
# cmakedefine01 SERVICE_DEBUG
#endif
Expand Down
32 changes: 0 additions & 32 deletions Kernel/Debug.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
#cmakedefine01 CONTEXT_SWITCH_DEBUG
#endif

#ifndef CONTIGUOUS_VMOBJECT_DEBUG
#cmakedefine01 CONTIGUOUS_VMOBJECT_DEBUG
#endif

#ifndef DUMP_REGIONS_ON_CRASH
#cmakedefine01 DUMP_REGIONS_ON_CRASH
#endif
Expand All @@ -63,18 +59,10 @@
#cmakedefine01 E1000_DEBUG
#endif

#ifndef E1000E_DEBUG
#cmakedefine01 E1000E_DEBUG
#endif

#ifndef ETHERNET_DEBUG
#cmakedefine01 ETHERNET_DEBUG
#endif

#ifndef ETHERNET_VERY_DEBUG
#cmakedefine01 ETHERNET_VERY_DEBUG
#endif

#ifndef EXEC_DEBUG
#cmakedefine01 EXEC_DEBUG
#endif
Expand All @@ -95,14 +83,6 @@
#cmakedefine01 FAT_DEBUG
#endif

#ifndef FRAMEBUFFER_DEVICE_DEBUG
#cmakedefine01 FRAMEBUFFER_DEVICE_DEBUG
#endif

#ifndef FILEDESCRIPTION_DEBUG
#cmakedefine01 FILEDESCRIPTION_DEBUG
#endif

#ifndef FORK_DEBUG
#cmakedefine01 FORK_DEBUG
#endif
Expand Down Expand Up @@ -275,10 +255,6 @@
#cmakedefine01 RTL8168_DEBUG
#endif

#ifndef SB16_DEBUG
#cmakedefine01 SB16_DEBUG
#endif

#ifndef SCHEDULER_DEBUG
#cmakedefine01 SCHEDULER_DEBUG
#endif
Expand Down Expand Up @@ -351,10 +327,6 @@
#cmakedefine01 VMWARE_BACKDOOR_DEBUG
#endif

#ifndef VOLATILE_PAGE_RANGES_DEBUG
#cmakedefine01 VOLATILE_PAGE_RANGES_DEBUG
#endif

#ifndef VIRTIO_DEBUG
#cmakedefine01 VIRTIO_DEBUG
#endif
Expand All @@ -363,10 +335,6 @@
#cmakedefine01 VIRTUAL_CONSOLE_DEBUG
#endif

#ifndef VRA_DEBUG
#cmakedefine01 VRA_DEBUG
#endif

#ifndef WAITBLOCK_DEBUG
#cmakedefine01 WAITBLOCK_DEBUG
#endif
Expand Down
34 changes: 9 additions & 25 deletions Meta/CMake/all_the_debug_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,14 @@ set(CMAKE_DEBUG ON)
set(COMMIT_DEBUG ON)
set(COMPOSE_DEBUG ON)
set(CONTEXT_SWITCH_DEBUG ON)
set(CONTIGUOUS_VMOBJECT_DEBUG ON)
set(COPY_DEBUG ON)
set(CPP_DEBUG ON)
set(CPP_LANGUAGE_SERVER_DEBUG ON)
set(CRYPTO_DEBUG ON)
set(CSOCKET_DEBUG ON)
set(CSS_LOADER_DEBUG ON)
set(CSS_PARSER_DEBUG ON)
set(CSS_TOKENIZER_DEBUG ON)
set(CURSOR_TOOL_DEBUG ON)
set(DDS_DEBUG ON)
set(DEBUG_AUTOCOMPLETE ON)
set(DEBUG_CPP_LANGUAGE_SERVER ON)
set(DEFERRED_INVOKE_DEBUG ON)
set(DHCPV4CLIENT_DEBUG ON)
set(DHCPV4_DEBUG ON)
set(DIFF_DEBUG ON)
Expand All @@ -41,37 +35,30 @@ set(DUMP_REGIONS_ON_CRASH ON)
set(DWARF_DEBUG ON)
set(DYNAMIC_LOAD_DEBUG ON)
set(E1000_DEBUG ON)
set(E1000E_DEBUG ON)
set(EDITOR_DEBUG ON)
set(ELF_IMAGE_DEBUG ON)
set(EMOJI_DEBUG ON)
set(ESCAPE_SEQUENCE_DEBUG ON)
set(ETHERNET_DEBUG ON)
set(ETHERNET_VERY_DEBUG ON)
set(EVENT_DEBUG ON)
set(EVENTLOOP_DEBUG ON)
set(EXEC_DEBUG ON)
set(EXT2_BLOCKLIST_DEBUG ON)
set(EXT2_DEBUG ON)
set(EXT2_VERY_DEBUG ON)
set(FAT_DEBUG ON)
set(FILE_CONTENT_DEBUG ON)
set(FILEDESCRIPTION_DEBUG ON)
set(FILE_WATCHER_DEBUG ON)
set(FILL_PATH_DEBUG ON)
set(FORK_DEBUG ON)
set(FRAMEBUFFER_DEVICE_DEBUG ON)
set(FUTEX_DEBUG ON)
set(FUTEXQUEUE_DEBUG ON)
set(GEMINI_DEBUG ON)
set(GEMINIJOB_DEBUG ON)
set(GENERATE_DEBUG_CODE ON)
set(GENERATE_DEBUG ON)
set(GHASH_PROCESS_DEBUG ON)
set(GIF_DEBUG ON)
set(GL_DEBUG ON)
set(GLOBAL_DTORS_DEBUG ON)
set(GPT_DEBUG ON)
set(GZIP_DEBUG ON)
set(HEAP_DEBUG ON)
set(HEARTS_DEBUG ON)
set(HEX_DEBUG ON)
Expand All @@ -80,7 +67,6 @@ set(HPET_COMPARATOR_DEBUG ON)
set(HPET_DEBUG ON)
set(HTML_SCRIPT_DEBUG ON)
set(HTTPJOB_DEBUG ON)
set(HTTPSJOB_DEBUG ON)
set(HUNKS_DEBUG ON)
set(ICMP_DEBUG ON)
set(ICO_DEBUG ON)
Expand Down Expand Up @@ -125,8 +111,6 @@ set(MBR_DEBUG ON)
set(MEMORY_DEVICE_DEBUG ON)
set(MEMORY_DEBUG ON)
set(MENU_DEBUG ON)
set(MENUS_DEBUG ON)
set(MINIMIZE_ANIMATION_DEBUG ON)
set(MOUSE_DEBUG ON)
set(MOVE_DEBUG ON)
set(MULTIPROCESSOR_DEBUG ON)
Expand Down Expand Up @@ -161,8 +145,6 @@ set(RESOURCE_DEBUG ON)
set(ROUTING_DEBUG ON)
set(RSA_PARSE_DEBUG ON)
set(RTL8168_DEBUG ON)
set(SAFE_SYSCALL_DEBUG ON)
set(SB16_DEBUG ON)
set(SCHEDULER_DEBUG ON)
set(SCHEDULER_RUNNABLE_DEBUG ON)
set(SERVICE_DEBUG ON)
Expand Down Expand Up @@ -208,8 +190,6 @@ set(VFS_DEBUG ON)
set(VIRTIO_DEBUG ON)
set(VIRTUAL_CONSOLE_DEBUG ON)
set(VMWARE_BACKDOOR_DEBUG ON)
set(VOLATILE_PAGE_RANGES_DEBUG ON)
set(VRA_DEBUG ON)
set(WAITBLOCK_DEBUG ON)
set(WAITQUEUE_DEBUG ON)
set(WASI_DEBUG ON)
Expand Down Expand Up @@ -253,10 +233,14 @@ set(XML_PARSER_DEBUG ON)
# Immediately finds violations during boot, shouldn't be discoverable by people who aren't working on fixing.
# set(KMALLOC_VERIFY_NO_SPINLOCK_HELD ON)
# False positive: CONSOLE_OUT_TO_BOCHS_DEBUG_PORT is a flag for ConsoleDevice, not a feature.
# set(CONSOLE_OUT_TO_BOCHS_DEBUG_PORT)
# set(CONSOLE_OUT_TO_BOCHS_DEBUG_PORT ON)
# False positive: BOCHS_DEBUG_PORT represents an IO port constant
# set(BOCHS_DEBUG_PORT)
# set(BOCHS_DEBUG_PORT ON)
# False positive: IFF_DEBUG is an ioctl flag
# set(IFF_DEBUG)
# set(IFF_DEBUG ON)
# False positive: SO_DEBUG is a socket option
# set(SO_DEBUG)
# set(SO_DEBUG ON)
# False positive: ELF_DEBUG is the section name for debug symbols, not a debug flag.
# set(ELF_DEBUG ON)
# False positive: A32_DEBUG_INTERFACE is the name of a CPU feature, not a debug flag.
# set(IA32_DEBUG_INTERFACE ON)
15 changes: 6 additions & 9 deletions Meta/check-debug-flags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@ cd "${script_path}/.."

MISSING_FLAGS=n

# Check whether all_the_debug_macros.cmake sets all the flags used in C++ code.
while IFS= read -r FLAG; do
# Ignore false positives that are not debug flags.
if [ "$FLAG" = "ELF_DEBUG" ] || [ "$FLAG" = "IA32_DEBUG_INTERFACE" ]; then
continue
fi

# We simply search whether the CMakeLists.txt *ever* sets the flag.
# There are (basically) no false positives, but there might be false negatives,
# for example we intentionally don't check for commented-out lines here.
if ! grep -qF "set(${FLAG}" Meta/CMake/all_the_debug_macros.cmake ; then
# We intentionally don't check for commented-out lines,
# in order to keep track of false positives.
if ! grep -qF "set(${FLAG} ON)" Meta/CMake/all_the_debug_macros.cmake ; then
echo "'all_the_debug_macros.cmake' is missing ${FLAG}"
MISSING_FLAGS=y
fi
Expand Down Expand Up @@ -49,5 +44,7 @@ if [ "n" != "${MISSING_FLAGS}" ] ; then
echo "If you just added a new SOMETHING_DEBUG flag, that's great!"
echo "We want to enable all of these in automated builds, so that the code doesn't rot."
echo "Please add it to Meta/CMake/all_the_debug_macros.cmake"
echo "Or perhaps it's not a debug flag?"
echo "Please also add it to Meta/CMake/all_the_debug_macros.cmake"
exit 1
fi

0 comments on commit 173f872

Please sign in to comment.