@@ -133,6 +133,7 @@ struct conf_fprintf {
uint8_t hex_fmt:1;
uint8_t strip_inline:1;
uint8_t skip_emitting_atomic_typedefs:1;
+ uint8_t skip_emitting_errors:1;
};
struct cus;
@@ -944,6 +945,10 @@ size_t function__fprintf_stats(const struct tag *tag_func,
FILE *fp);
const char *function__prototype(const struct function *func,
const struct cu *cu, char *bf, size_t len);
+const char *function__prototype_conf(const struct function *func,
+ const struct cu *cu,
+ const struct conf_fprintf *conf,
+ char *bf, size_t len);
static __pure inline uint64_t function__addr(const struct function *func)
{
@@ -1102,21 +1102,33 @@ static size_t union__fprintf(struct type *type, const struct cu *cu,
conf->suffix ? " " : "", conf->suffix ?: "");
}
-const char *function__prototype(const struct function *func,
- const struct cu *cu, char *bf, size_t len)
+const char *function__prototype_conf(const struct function *func,
+ const struct cu *cu,
+ const struct conf_fprintf *conf,
+ char *bf, size_t len)
{
FILE *bfp = fmemopen(bf, len, "w");
if (bfp != NULL) {
- ftype__fprintf(&func->proto, cu, NULL, 0, 0, 0, true,
- &conf_fprintf__defaults, bfp);
+ ftype__fprintf(&func->proto, cu, NULL, 0, 0, 0, true, conf,
+ bfp);
fclose(bfp);
- } else
+ } else {
+ if (conf->skip_emitting_errors)
+ return NULL;
snprintf(bf, len, "<ERROR(%s): fmemopen failed!>", __func__);
+ }
return bf;
}
+const char *function__prototype(const struct function *func,
+ const struct cu *cu, char *bf, size_t len)
+{
+ return function__prototype_conf(func, cu, &conf_fprintf__defaults,
+ bf, len);
+}
+
size_t ftype__fprintf_parms(const struct ftype *ftype,
const struct cu *cu, int indent,
const struct conf_fprintf *conf, FILE *fp)
function__prototype() writes the function prototype to the passed-in buffer, but uses the default conf_fprint structure which prints parameter names. Generalize into function__prototype_conf() so that callers can pass in their own conf_fprintf; this will be useful for generating prototype strings for type matching. Signed-off-by: Alan Maguire <alan.maguire@oracle.com> --- dwarves.h | 5 +++++ dwarves_fprintf.c | 22 +++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-)