trace_probe.c (f8bade6c9a6213c2c5ba6e5bf32415ecab6e41e5) | trace_probe.c (f2cc020d7876de7583feb52ec939a32419cf9468) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Common code for probe-based Dynamic events. 4 * 5 * This code was copied from kernel/trace/trace_kprobe.c written by 6 * Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> 7 * 8 * Updates to make this generic: --- 154 unchanged lines hidden (view full) --- 163void __trace_probe_log_err(int offset, int err_type) 164{ 165 char *command, *p; 166 int i, len = 0, pos = 0; 167 168 if (!trace_probe_log.argv) 169 return; 170 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Common code for probe-based Dynamic events. 4 * 5 * This code was copied from kernel/trace/trace_kprobe.c written by 6 * Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> 7 * 8 * Updates to make this generic: --- 154 unchanged lines hidden (view full) --- 163void __trace_probe_log_err(int offset, int err_type) 164{ 165 char *command, *p; 166 int i, len = 0, pos = 0; 167 168 if (!trace_probe_log.argv) 169 return; 170 |
171 /* Recalcurate the length and allocate buffer */ | 171 /* Recalculate the length and allocate buffer */ |
172 for (i = 0; i < trace_probe_log.argc; i++) { 173 if (i == trace_probe_log.index) 174 pos = len; 175 len += strlen(trace_probe_log.argv[i]) + 1; 176 } 177 command = kzalloc(len, GFP_KERNEL); 178 if (!command) 179 return; 180 181 if (trace_probe_log.index >= trace_probe_log.argc) { 182 /** 183 * Set the error position is next to the last arg + space. 184 * Note that len includes the terminal null and the cursor | 172 for (i = 0; i < trace_probe_log.argc; i++) { 173 if (i == trace_probe_log.index) 174 pos = len; 175 len += strlen(trace_probe_log.argv[i]) + 1; 176 } 177 command = kzalloc(len, GFP_KERNEL); 178 if (!command) 179 return; 180 181 if (trace_probe_log.index >= trace_probe_log.argc) { 182 /** 183 * Set the error position is next to the last arg + space. 184 * Note that len includes the terminal null and the cursor |
185 * appaers at pos + 1. | 185 * appears at pos + 1. |
186 */ 187 pos = len; 188 offset = 0; 189 } 190 191 /* And make a command string from argv array */ 192 p = command; 193 for (i = 0; i < trace_probe_log.argc; i++) { --- 393 unchanged lines hidden (view full) --- 587 trace_probe_log_err(offset + t2 - arg, 588 ARRAY_TOO_BIG); 589 return -EINVAL; 590 } 591 } 592 } 593 594 /* | 186 */ 187 pos = len; 188 offset = 0; 189 } 190 191 /* And make a command string from argv array */ 192 p = command; 193 for (i = 0; i < trace_probe_log.argc; i++) { --- 393 unchanged lines hidden (view full) --- 587 trace_probe_log_err(offset + t2 - arg, 588 ARRAY_TOO_BIG); 589 return -EINVAL; 590 } 591 } 592 } 593 594 /* |
595 * Since $comm and immediate string can not be dereferred, | 595 * Since $comm and immediate string can not be dereferenced, |
596 * we can find those by strcmp. 597 */ 598 if (strcmp(arg, "$comm") == 0 || strncmp(arg, "\\\"", 2) == 0) { 599 /* The type of $comm must be "string", and not an array. */ 600 if (parg->count || (t && strcmp(t, "string"))) 601 return -EINVAL; 602 parg->type = find_fetch_type("string"); 603 } else --- 550 unchanged lines hidden --- | 596 * we can find those by strcmp. 597 */ 598 if (strcmp(arg, "$comm") == 0 || strncmp(arg, "\\\"", 2) == 0) { 599 /* The type of $comm must be "string", and not an array. */ 600 if (parg->count || (t && strcmp(t, "string"))) 601 return -EINVAL; 602 parg->type = find_fetch_type("string"); 603 } else --- 550 unchanged lines hidden --- |