[v4,27/39] dyndbg: update "ddcmd =:foo" behavior

Message ID 20240210235009.2405808-28-ukaszb@chromium.org
State New
Headers
Series dyndbg: add support for writing debug logs to trace |

Commit Message

Łukasz Bartosik Feb. 10, 2024, 11:49 p.m. UTC
  Previously the following commands were equivalent

      ddcmd =_:foo
      ddcmd =:foo

and both unset all flags and set foo label.

This patch modifies the behavior of the command

      ddcmd =:foo

to set (only) the foo label and preserve the flags.

Signed-off-by: Łukasz Bartosik <ukaszb@chromium.org>
---
 lib/dynamic_debug.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Patch

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 3a9dd73357c8..7723bb7dfc46 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -882,6 +882,7 @@  static int ddebug_parse_query(char *words[], int nwords,
  */
 static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers)
 {
+	bool explicit_no_flags = !strchr(str, '_') ? false : true;
 	read_flag_args_f read_args;
 	int op, i;
 	char *fst;
@@ -927,6 +928,14 @@  static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers)
 	case '=':
 		/* modifiers->flags already set */
 		modifiers->mask = 0;
+
+		/*
+		 * cover the case where "ddcmd =:foo" sets (only)
+		 * the foo label, since no flags are given
+		 */
+		if (!explicit_no_flags && !modifiers->flags &&
+		    modifiers->trace_dst != DST_NOT_SET)
+			modifiers->mask = ~0U;
 		break;
 	case '+':
 		modifiers->mask = ~0U;