blackmagic-debug / blackmagic

In application debugger for ARM Cortex microcontrollers.
GNU General Public License v3.0
3.22k stars 767 forks source link

Fix: Simplify debug log guard in imxrt.c #1818

Closed ALTracer closed 4 months ago

ALTracer commented 4 months ago

Detailed description

This is a contextual follow-up to #1517, also see PR1533-PR1534, and really it's #1684 which enables this PR.

In file included from ../src/target/imxrt.c:34:
../src/target/imxrt.c: In function 'imxrt_probe':
../src/target/imxrt.c:224:50: error: 'boot_mode' undeclared (first use in this function)
  224 |         DEBUG_TARGET("i.MXRT boot mode is %x\n", boot_mode);
      |                                                  ^~~~~~~~~

Your checklist for this pull request

Closing issues

ALTracer commented 4 months ago

Extras:

Updating this allows developers to have extra 3 KiB of TARGET loglevel diagnostics in platforms like blackpill-f411ce on top of existing 16 KiB of ERROR+WARN+INFO; or extra 2 KiB on native/stlink/swlink which disable some -Dtargets already.

diff --git a/src/include/general.h b/src/include/general.h
index 83a2e3a3..91f15796 100644
--- a/src/include/general.h
+++ b/src/include/general.h
@@ -102,2 +102,3 @@
 #define DEBUG_INFO(...)  PLATFORM_PRINTF(__VA_ARGS__)
+#define DEBUG_TARGET(...) PLATFORM_PRINTF(__VA_ARGS__)
 #else
@@ -109,2 +110,4 @@
 #define DEBUG_INFO_IS_NOOP
+#define DEBUG_TARGET(...) PRINT_NOOP(__VA_ARGS__)
+#define DEBUG_TARGET_IS_NOOP
 #endif
@@ -112,4 +115,2 @@
 #define DEBUG_GDB_IS_NOOP
-#define DEBUG_TARGET(...) PRINT_NOOP(__VA_ARGS__)
-#define DEBUG_TARGET_IS_NOOP
 #define DEBUG_PROTO(...) PRINT_NOOP(__VA_ARGS__)

Doing a $ grep -rn DEBUG_TARGET\( ./src/target/ | wc -l I see 33 instances of it, and also PROBE() which is an important indication for which cortexm_probe()-dispatched routines are invoked per discovered target.