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

From: Łukasz Bartosik
Date: Sat Feb 10 2024 - 18:57:10 EST


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@xxxxxxxxxxxx>
---
lib/dynamic_debug.c | 9 +++++++++
1 file changed, 9 insertions(+)

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;
--
2.43.0.687.g38aa6559b0-goog