diff options
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | TODO | 10 | ||||
-rw-r--r-- | test_structs.c | 35 |
3 files changed, 44 insertions, 6 deletions
@@ -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) @@ -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; +} |