summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2018-08-23 14:27:20 +0900
committerDominique Martinet <asmadeus@codewreck.org>2018-08-23 14:27:20 +0900
commit0388ee68f38667e4bbc8fddca3a0c2c9f9461c1e (patch)
tree73aaab1468c933196236c37f9cd2be1604e884c7
parentb50bd2b3cb9a4d72aba38faece8f53d2d24e0303 (diff)
add test object file
-rw-r--r--Makefile5
-rw-r--r--TODO10
-rw-r--r--test_structs.c35
3 files changed, 44 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 6f02c3e..8ab9acd 100644
--- a/Makefile
+++ b/Makefile
@@ -2,10 +2,13 @@ SOURCES=dwarf-extract-struct.c
OBJECTS=$(SOURCES:.c=.o)
MAIN=dwarf-extract-struct
+TEST_SOURCES=test_structs.c
+TEST_OBJECTS=$(TEST_SOURCES:.c=.o)
+
CFLAGS+=-g -Wall -Werror
LDFLAGS=-ldwarf -lelf
-all: $(MAIN)
+all: $(MAIN) $(TEST_OBJECTS)
$(MAIN): $(OBJECTS)
diff --git a/TODO b/TODO
index bcabb9c..838816b 100644
--- a/TODO
+++ b/TODO
@@ -1,16 +1,11 @@
Orderless todo:
- - add option to extract all members of given struct
-
- add option to recursively dump any struct inside requested struct
(only fill in padding or resue option to extract all members? figure
another syntax to specify substruct.field?)
- add option to list all the structs available in a file
- - add option to list all the fields available for a struct (I guess
-that's close enough to extracting, but might be more human readable)
-
- refactor some (in particular add wrappers/helpers around dwarf
functions so we abort properly checking both error and !ok, with
clear error messages)
@@ -21,3 +16,8 @@ clear error messages)
(need to be careful about embedded structs when we're not in recurse
mode? or have a mode that replaces 'em with char[x]?)
+ - refactor to not print immediately but fill a tree, so we could get
+rid of successive padding when elem size follows
+
+ - Fix anonymous struct/unions (need some sort of recursivity; probably
+depends intermediate representation)
diff --git a/test_structs.c b/test_structs.c
new file mode 100644
index 0000000..bcedeea
--- /dev/null
+++ b/test_structs.c
@@ -0,0 +1,35 @@
+struct simple {
+ int first;
+ long int second;
+};
+
+struct simple_union {
+ int zeroth;
+ union {
+ int first;
+ long int second;
+ };
+ int third;
+};
+
+struct simple_bitfield {
+ char first:1;
+ char second:2;
+};
+
+struct array_in_union {
+ union {
+ char first[12];
+ int second;
+ };
+};
+
+/* need to use the structs to have them embedded */
+void use_structs(void) {
+ struct simple simple __attribute__((unused));
+ struct simple_union simple_union __attribute__((unused));
+ struct simple_bitfield simple_bitfield __attribute__((unused));
+ struct array_in_union array_in_union __attribute__((unused));
+
+ return;
+}