From d06ed83faa07de5bbba50f5bb70ed0bbbffdac32 Mon Sep 17 00:00:00 2001 From: Paul Cacheux Date: Mon, 2 Dec 2024 10:21:23 +0100 Subject: [PATCH] [CWS-2966] add missing cws-instrumentation flags in attach mode (#31637) --- .../subcommands/tracecmd/trace.go | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/cmd/cws-instrumentation/subcommands/tracecmd/trace.go b/cmd/cws-instrumentation/subcommands/tracecmd/trace.go index 3fa092606bc78..a8ad4238b2483 100644 --- a/cmd/cws-instrumentation/subcommands/tracecmd/trace.go +++ b/cmd/cws-instrumentation/subcommands/tracecmd/trace.go @@ -149,19 +149,17 @@ func Command() []*cobra.Command { go func(set []int) { defer wg.Done() - args := []string{"trace"} - - if params.ProcScanDisabled { - args = append(args, fmt.Sprintf(`--%s`, disableProcScanOpt)) - } - if params.Async { - args = append(args, fmt.Sprintf(`--%s`, asyncOpt)) + args := []string{ + "trace", + fmt.Sprintf(`--%s`, probeAddrOpt), + params.ProbeAddr, } + if params.Verbose { args = append(args, fmt.Sprintf(`--%s`, verboseOpt)) } - if params.StatsDisabled { - args = append(args, fmt.Sprintf(`--%s`, disableStatsOpt)) + if params.Debug { + args = append(args, fmt.Sprintf(`--%s`, debugOpt)) } if params.UID != -1 { args = append(args, fmt.Sprintf(`--%s`, uidOpt), fmt.Sprintf(`%d`, params.UID)) @@ -169,7 +167,21 @@ func Command() []*cobra.Command { if params.GID != -1 { args = append(args, fmt.Sprintf(`--%s`, gidOpt), fmt.Sprintf(`%d`, params.GID)) } - args = append(args, fmt.Sprintf(`--%s`, probeAddrOpt), params.ProbeAddr) + if params.Async { + args = append(args, fmt.Sprintf(`--%s`, asyncOpt)) + } + if params.StatsDisabled { + args = append(args, fmt.Sprintf(`--%s`, disableStatsOpt)) + } + if params.ProcScanDisabled { + args = append(args, fmt.Sprintf(`--%s`, disableProcScanOpt)) + } + if params.ScanProcEvery != "" { + args = append(args, fmt.Sprintf(`--%s`, scanProcEveryOpt), params.ScanProcEvery) + } + if params.SeccompDisabled { + args = append(args, fmt.Sprintf(`--%s`, disableSeccompOpt)) + } for _, pid := range set { args = append(args, fmt.Sprintf(`--%s`, pidOpt), fmt.Sprintf(`%d`, pid))