diff options
Diffstat (limited to 'lib/dynamic_debug.c')
| -rw-r--r-- | lib/dynamic_debug.c | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5276b99ca650..99fec3ae405a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/sysctl.h> | 24 | #include <linux/sysctl.h> |
| 25 | #include <linux/ctype.h> | 25 | #include <linux/ctype.h> |
| 26 | #include <linux/string.h> | 26 | #include <linux/string.h> |
| 27 | #include <linux/string_helpers.h> | ||
| 27 | #include <linux/uaccess.h> | 28 | #include <linux/uaccess.h> |
| 28 | #include <linux/dynamic_debug.h> | 29 | #include <linux/dynamic_debug.h> |
| 29 | #include <linux/debugfs.h> | 30 | #include <linux/debugfs.h> |
| @@ -276,48 +277,6 @@ static inline int parse_lineno(const char *str, unsigned int *val) | |||
| 276 | return 0; | 277 | return 0; |
| 277 | } | 278 | } |
| 278 | 279 | ||
| 279 | /* | ||
| 280 | * Undo octal escaping in a string, inplace. This is useful to | ||
| 281 | * allow the user to express a query which matches a format | ||
| 282 | * containing embedded spaces. | ||
| 283 | */ | ||
| 284 | #define isodigit(c) ((c) >= '0' && (c) <= '7') | ||
| 285 | static char *unescape(char *str) | ||
| 286 | { | ||
| 287 | char *in = str; | ||
| 288 | char *out = str; | ||
| 289 | |||
| 290 | while (*in) { | ||
| 291 | if (*in == '\\') { | ||
| 292 | if (in[1] == '\\') { | ||
| 293 | *out++ = '\\'; | ||
| 294 | in += 2; | ||
| 295 | continue; | ||
| 296 | } else if (in[1] == 't') { | ||
| 297 | *out++ = '\t'; | ||
| 298 | in += 2; | ||
| 299 | continue; | ||
| 300 | } else if (in[1] == 'n') { | ||
| 301 | *out++ = '\n'; | ||
| 302 | in += 2; | ||
| 303 | continue; | ||
| 304 | } else if (isodigit(in[1]) && | ||
| 305 | isodigit(in[2]) && | ||
| 306 | isodigit(in[3])) { | ||
| 307 | *out++ = (((in[1] - '0') << 6) | | ||
| 308 | ((in[2] - '0') << 3) | | ||
| 309 | (in[3] - '0')); | ||
| 310 | in += 4; | ||
| 311 | continue; | ||
| 312 | } | ||
| 313 | } | ||
| 314 | *out++ = *in++; | ||
| 315 | } | ||
| 316 | *out = '\0'; | ||
| 317 | |||
| 318 | return str; | ||
| 319 | } | ||
| 320 | |||
| 321 | static int check_set(const char **dest, char *src, char *name) | 280 | static int check_set(const char **dest, char *src, char *name) |
| 322 | { | 281 | { |
| 323 | int rc = 0; | 282 | int rc = 0; |
| @@ -371,8 +330,10 @@ static int ddebug_parse_query(char *words[], int nwords, | |||
| 371 | } else if (!strcmp(words[i], "module")) { | 330 | } else if (!strcmp(words[i], "module")) { |
| 372 | rc = check_set(&query->module, words[i+1], "module"); | 331 | rc = check_set(&query->module, words[i+1], "module"); |
| 373 | } else if (!strcmp(words[i], "format")) { | 332 | } else if (!strcmp(words[i], "format")) { |
| 374 | rc = check_set(&query->format, unescape(words[i+1]), | 333 | string_unescape_inplace(words[i+1], UNESCAPE_SPACE | |
| 375 | "format"); | 334 | UNESCAPE_OCTAL | |
| 335 | UNESCAPE_SPECIAL); | ||
| 336 | rc = check_set(&query->format, words[i+1], "format"); | ||
| 376 | } else if (!strcmp(words[i], "line")) { | 337 | } else if (!strcmp(words[i], "line")) { |
| 377 | char *first = words[i+1]; | 338 | char *first = words[i+1]; |
| 378 | char *last = strchr(first, '-'); | 339 | char *last = strchr(first, '-'); |
