perf probe: No need to use formatting strbuf method

We have addch() for chars, add() for fixed size data, and addstr() for
variable length strings, use them.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-0ap02fn2xtvpduj2j6b2o1j4@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a610f5cb
...@@ -915,7 +915,7 @@ int die_get_typename(Dwarf_Die *vr_die, struct strbuf *buf) ...@@ -915,7 +915,7 @@ int die_get_typename(Dwarf_Die *vr_die, struct strbuf *buf)
tmp = "*"; tmp = "*";
else if (tag == DW_TAG_subroutine_type) { else if (tag == DW_TAG_subroutine_type) {
/* Function pointer */ /* Function pointer */
strbuf_addf(buf, "(function_type)"); strbuf_add(buf, "(function_type)", 15);
return 0; return 0;
} else { } else {
if (!dwarf_diename(&type)) if (!dwarf_diename(&type))
...@@ -932,7 +932,7 @@ int die_get_typename(Dwarf_Die *vr_die, struct strbuf *buf) ...@@ -932,7 +932,7 @@ int die_get_typename(Dwarf_Die *vr_die, struct strbuf *buf)
} }
ret = die_get_typename(&type, buf); ret = die_get_typename(&type, buf);
if (ret == 0) if (ret == 0)
strbuf_addf(buf, "%s", tmp); strbuf_addstr(buf, tmp);
return ret; return ret;
} }
...@@ -951,7 +951,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf) ...@@ -951,7 +951,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf)
ret = die_get_typename(vr_die, buf); ret = die_get_typename(vr_die, buf);
if (ret < 0) { if (ret < 0) {
pr_debug("Failed to get type, make it unknown.\n"); pr_debug("Failed to get type, make it unknown.\n");
strbuf_addf(buf, "(unknown_type)"); strbuf_add(buf, " (unknown_type)", 14);
} }
strbuf_addf(buf, "\t%s", dwarf_diename(vr_die)); strbuf_addf(buf, "\t%s", dwarf_diename(vr_die));
...@@ -1013,7 +1013,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die, ...@@ -1013,7 +1013,7 @@ static int die_get_var_innermost_scope(Dwarf_Die *sp_die, Dwarf_Die *vr_die,
} }
if (!first) if (!first)
strbuf_addf(buf, "]>"); strbuf_add(buf, "]>", 2);
out: out:
free(scopes); free(scopes);
...@@ -1076,7 +1076,7 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf) ...@@ -1076,7 +1076,7 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf)
} }
if (!first) if (!first)
strbuf_addf(buf, "]>"); strbuf_add(buf, "]>", 2);
return ret; return ret;
} }
...@@ -2179,7 +2179,7 @@ static int perf_probe_event__sprintf(const char *group, const char *event, ...@@ -2179,7 +2179,7 @@ static int perf_probe_event__sprintf(const char *group, const char *event,
strbuf_addf(result, " in %s", module); strbuf_addf(result, " in %s", module);
if (pev->nargs > 0) { if (pev->nargs > 0) {
strbuf_addstr(result, " with"); strbuf_add(result, " with", 5);
for (i = 0; i < pev->nargs; i++) { for (i = 0; i < pev->nargs; i++) {
ret = synthesize_perf_probe_arg(&pev->args[i], ret = synthesize_perf_probe_arg(&pev->args[i],
buf, 128); buf, 128);
......
...@@ -1314,18 +1314,18 @@ static int collect_variables_cb(Dwarf_Die *die_mem, void *data) ...@@ -1314,18 +1314,18 @@ static int collect_variables_cb(Dwarf_Die *die_mem, void *data)
if (probe_conf.show_location_range) { if (probe_conf.show_location_range) {
if (!externs) { if (!externs) {
if (ret) if (ret)
strbuf_addf(&buf, "[INV]\t"); strbuf_add(&buf, "[INV]\t", 6);
else else
strbuf_addf(&buf, "[VAL]\t"); strbuf_add(&buf, "[VAL]\t", 6);
} else } else
strbuf_addf(&buf, "[EXT]\t"); strbuf_add(&buf, "[EXT]\t", 6);
} }
ret2 = die_get_varname(die_mem, &buf); ret2 = die_get_varname(die_mem, &buf);
if (!ret2 && probe_conf.show_location_range && if (!ret2 && probe_conf.show_location_range &&
!externs) { !externs) {
strbuf_addf(&buf, "\t"); strbuf_addch(&buf, '\t');
ret2 = die_get_var_range(&af->pf.sp_die, ret2 = die_get_var_range(&af->pf.sp_die,
die_mem, &buf); die_mem, &buf);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment