summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-08-11 16:28:31 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-08-11 16:28:31 +0000
commit3c4e815b5cb5e836ef45a4f88f0afaaeab360de8 (patch)
tree38f01525cee66e2ef849efb6119c982c8057b453 /usr.bin
parentd7396281c73c0f5cca41425733e77be22185c919 (diff)
Do not insert random name for anonymous member.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ctfconv/ctfconv.c4
-rw-r--r--usr.bin/ctfconv/generate.c8
-rw-r--r--usr.bin/ctfconv/itype.h5
-rw-r--r--usr.bin/ctfconv/parse.c22
4 files changed, 24 insertions, 15 deletions
diff --git a/usr.bin/ctfconv/ctfconv.c b/usr.bin/ctfconv/ctfconv.c
index 51b1d90f461..7fa2a7dd9fe 100644
--- a/usr.bin/ctfconv/ctfconv.c
+++ b/usr.bin/ctfconv/ctfconv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ctfconv.c,v 1.2 2017/08/11 14:58:56 jasper Exp $ */
+/* $OpenBSD: ctfconv.c,v 1.3 2017/08/11 16:28:29 mpi Exp $ */
/*
* Copyright (c) 2016-2017 Martin Pieuchot
@@ -382,7 +382,7 @@ dump_type(struct itype *it)
type_name(it), it->it_size);
TAILQ_FOREACH(im, &it->it_members, im_next) {
printf("\t%s type=%u off=%zd\n",
- (im->im_flags & ITM_ANON) ? "unknown" : im->im_name,
+ (im_name(im) == NULL) ? "unknown" : im_name(im),
im->im_refp->it_idx, im->im_off);
}
printf("\n");
diff --git a/usr.bin/ctfconv/generate.c b/usr.bin/ctfconv/generate.c
index 6e95c851b99..2a26ee69bb1 100644
--- a/usr.bin/ctfconv/generate.c
+++ b/usr.bin/ctfconv/generate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: generate.c,v 1.2 2017/08/11 14:58:56 jasper Exp $ */
+/* $OpenBSD: generate.c,v 1.3 2017/08/11 16:28:30 mpi Exp $ */
/*
* Copyright (c) 2017 Martin Pieuchot
@@ -230,7 +230,7 @@ imcs_add_type(struct imcs *imcs, struct itype *it)
memset(&ctm, 0, sizeof(ctm));
TAILQ_FOREACH(im, &it->it_members, im_next) {
ctm.ctm_name =
- imcs_add_string(imcs, im->im_name);
+ imcs_add_string(imcs, im_name(im));
ctm.ctm_type = im->im_refp->it_idx;
ctm.ctm_offset = im->im_off;
@@ -242,7 +242,7 @@ imcs_add_type(struct imcs *imcs, struct itype *it)
memset(&ctlm, 0, sizeof(ctlm));
TAILQ_FOREACH(im, &it->it_members, im_next) {
ctlm.ctlm_name =
- imcs_add_string(imcs, im->im_name);
+ imcs_add_string(imcs, im_name(im));
ctlm.ctlm_type = im->im_refp->it_idx;
ctlm.ctlm_offsethi =
CTF_OFFSET_TO_LMEMHI(im->im_off);
@@ -268,7 +268,7 @@ imcs_add_type(struct imcs *imcs, struct itype *it)
TAILQ_FOREACH(im, &it->it_members, im_next) {
struct ctf_enum cte;
- cte.cte_name = imcs_add_string(imcs, im->im_name);
+ cte.cte_name = imcs_add_string(imcs, im_name(im));
cte.cte_value = im->im_ref;
dbuf_copy(&imcs->body, &cte, sizeof(cte));
diff --git a/usr.bin/ctfconv/itype.h b/usr.bin/ctfconv/itype.h
index 3c0d902c539..314c7fed08d 100644
--- a/usr.bin/ctfconv/itype.h
+++ b/usr.bin/ctfconv/itype.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: itype.h,v 1.2 2017/08/11 14:58:56 jasper Exp $ */
+/* $OpenBSD: itype.h,v 1.3 2017/08/11 16:28:30 mpi Exp $ */
/*
* Copyright (c) 2016-2017 Martin Pieuchot
@@ -75,7 +75,7 @@ struct imember {
size_t im_off; /* field offset in struct/union */
struct itype *im_refp; /* resolved CTF type */
unsigned int im_flags; /* parser flags */
-#define ITM_ANON 0x01 /* member without name */
+#define IMF_ANON 0x01 /* member without name */
};
/*
@@ -100,5 +100,6 @@ RB_PROTOTYPE(isymb_tree, itype, it_node, it_name_cmp);
struct itype *it_dup(struct itype *);
const char *it_name(struct itype *);
+const char *im_name(struct imember *);
#endif /*_ITTYPE_H_ */
diff --git a/usr.bin/ctfconv/parse.c b/usr.bin/ctfconv/parse.c
index 3cfa227a387..5ce2f275105 100644
--- a/usr.bin/ctfconv/parse.c
+++ b/usr.bin/ctfconv/parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.c,v 1.2 2017/08/11 14:58:56 jasper Exp $ */
+/* $OpenBSD: parse.c,v 1.3 2017/08/11 16:28:30 mpi Exp $ */
/*
* Copyright (c) 2016-2017 Martin Pieuchot
@@ -233,7 +233,7 @@ it_dup(struct itype *it)
copit->it_nelems = it->it_nelems;
TAILQ_FOREACH(im, &it->it_members, im_next) {
- copim = im_new(im->im_name, im->im_ref, im->im_off);
+ copim = im_new(im_name(im), im->im_ref, im->im_off);
copim->im_refp = im->im_refp;
TAILQ_INSERT_TAIL(&copit->it_members, copim, im_next);
}
@@ -367,7 +367,7 @@ im_new(const char *name, size_t ref, size_t off)
im->im_off = off;
im->im_refp = NULL;
if (name == NULL) {
- im->im_flags = ITM_ANON;
+ im->im_flags = IMF_ANON;
} else {
size_t n;
@@ -381,6 +381,15 @@ im_new(const char *name, size_t ref, size_t off)
return im;
}
+const char *
+im_name(struct imember *im)
+{
+ if (!(im->im_flags & IMF_ANON))
+ return im->im_name;
+
+ return NULL;
+}
+
void
cu_stat(void)
{
@@ -436,10 +445,9 @@ cu_resolve(struct dwcu *dcu, struct itype_queue *cutq, struct ioff_tree *cuot)
if (toresolve)
printf(": %d members", toresolve);
TAILQ_FOREACH(im, &it->it_members, im_next) {
- if (im->im_refp == NULL) {
- printf("\n%zu: %s", im->im_ref,
- im->im_name);
- }
+ if (im->im_refp != NULL)
+ continue;
+ printf("\n%zu: %s", im->im_ref, im_name(im));
}
printf("\n");
}