Skip to content

Commit ddbc20c

Browse files
AryanBakliwalti-mo
authored andcommitted
fix(tracefs): allow '-' in tracepoint group names
Signed-off-by: Aryan Bakliwal <[email protected]>
1 parent 5031e28 commit ddbc20c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

internal/tracefs/kprobe.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ func RandomGroup(prefix string) (string, error) {
7272
}
7373

7474
// validIdentifier implements the equivalent of a regex match
75-
// against "^[a-zA-Z_][0-9a-zA-Z_]*$".
75+
// against "^[a-zA-Z_][0-9a-zA-Z_-]*$".
7676
//
77-
// Trace event groups, names and kernel symbols must adhere to this set
78-
// of characters. Non-empty, first character must not be a number, all
79-
// characters must be alphanumeric or underscore.
77+
// Trace event groups, names and kernel symbols must adhere to this set of
78+
// characters. Non-empty, first character must not be a number or hyphen, all
79+
// characters must be alphanumeric, underscore or hyphen.
8080
func validIdentifier(s string) bool {
8181
if len(s) < 1 {
8282
return false
@@ -86,7 +86,7 @@ func validIdentifier(s string) bool {
8686
case c >= 'a' && c <= 'z':
8787
case c >= 'A' && c <= 'Z':
8888
case c == '_':
89-
case i > 0 && c >= '0' && c <= '9':
89+
case i > 0 && (c == '-' || c >= '0' && c <= '9'):
9090

9191
default:
9292
return false

internal/tracefs/perf_event_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ func TestValidIdentifier(t *testing.T) {
4242
{"underscore first", "__x64_syscall", false},
4343
{"contains number", "bpf_trace_run1", false},
4444
{"underscore", "_", false},
45-
{"contains dash", "-EINVAL", true},
45+
{"leading dash", "-EINVAL", true},
4646
{"contains number", "all0wed", false},
47+
{"contains dash", "trace-group", false},
4748
}
4849

4950
for _, tt := range tests {

0 commit comments

Comments
 (0)