[PATCH dwarves 1/3] dwarves_fprintf: generalize function prototype print to support passing conf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 dwarves.h         |  5 +++++
 dwarves_fprintf.c | 22 +++++++++++++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/dwarves.h b/dwarves.h
index e92b2fd..d04a36d 100644
--- a/dwarves.h
+++ b/dwarves.h
@@ -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)
 {
diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c
index 30355b4..5c6bf9c 100644
--- a/dwarves_fprintf.c
+++ b/dwarves_fprintf.c
@@ -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)
-- 
1.8.3.1




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux