diff --git a/README.md b/README.md index 42f89344..9548ca83 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ 12. [Notes On Multiple DWARF Versions](#multiple_dwarf_versions) 13. [Bitfields](#Bitfields) 14. [Docker Dev Environments](#docker_dev_env) +15. [Union Support](#union_support) ## Dependencies * `libdwarf-dev` @@ -322,6 +323,7 @@ As juicer evolves, dwarf support will grow and evolve as well. At the moment, we | DW_MACRO_define | This tag represents define macros such as "#define CFE_MISSION_ES_PERF_MAX_IDS 128"| | DW_AT_decl_file | This tag represents the file where a certain symbol is declared. Very useful for traceability of source code.| | DW_AT_encoding | The encoding of base type. For example; "unsigned int" will have encoding "DW_ATE_unsigned". This is what the "encodings" table is for in the SQLITE db.| +| DW_TAG_union_type | The tag used for unions. For example; `union Object { int32_t id; int32_t bit_field : 10; uint8_t data[4];};`.| For more details on the DWARF debugging format, go on [here](http://www.dwarfstd.org/doc/DWARF4.pdf). @@ -433,5 +435,29 @@ For example `make docker-ubuntu22-build-dev` will start a dev environment inside The repo is mounted as a volume under "/home/docker/juicer" so developers can make their changes on the host and build inside the container. +# Union Support + +Given the following union: + +```C +union Object +{ + int32_t id; + int32_t bit_field : 10; + uint8_t data[4]; +}; + +``` + +The union is represented as such in the SQLITE db: + + +![bit_packed_fields](Images/union_symbol_tbl.png "symbols-table") + +![bit_packed_fields](Images/union_fields_tbl.png "fields-table") + +Notice that the byte_offset is `NULL` for the fields that belong to the union. This is how consumers (such as [auto-yamcs](https://github.com/WindhoverLabs/auto-yamcs)) can make a distinction between unions and structs. + + Documentation updated on September 19, 2024