Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add union support #41

Merged
merged 128 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
717ec8e
Merge branch 'develop' into 'master'
mbenson1 May 26, 2024
0bd9bc9
Merge branch 'develop'
mbenson1 May 26, 2024
911817a
Merge branch 'develop'
mbenson1 May 26, 2024
523888c
-Write macro records correctly. Fixes #7
lorenzo-gomez-windhover May 31, 2024
32f52e6
-Cleanup
lorenzo-gomez-windhover May 31, 2024
69e703c
-Update unit testing for draco patterns. WIP.
lorenzo-gomez-windhover Jul 25, 2024
c18f9e9
-Update eclipse project
lorenzo-gomez-windhover Jul 26, 2024
2c15aff
-Minimally functional target_symbol
lorenzo-gomez-windhover Jul 26, 2024
a92a7fb
-Do not store row id for symbol target updates
lorenzo-gomez-windhover Jul 26, 2024
d4d4996
-Update github CI
lorenzo-gomez-windhover Aug 26, 2024
8cf80c1
-Docker config for CI
lorenzo-gomez-windhover Aug 26, 2024
705b578
-Point submodules to github
lorenzo-gomez-windhover Aug 26, 2024
cbfad85
-Cleanup
lorenzo-gomez-windhover Aug 26, 2024
c724902
-Add symbols and encoding mappings. WIP.
lorenzo-gomez-windhover Aug 30, 2024
f09b5cf
-Add symbols and encoding mappings. WIP.
lorenzo-gomez-windhover Sep 3, 2024
12b6b17
Merge remote-tracking branch 'origin/7-write-macro-records-correctly'…
lorenzo-gomez-windhover Sep 3, 2024
b1a9e37
Writer DWARF5 ecodings to encodings table
lorenzo-gomez-windhover Sep 3, 2024
186880c
-Add minimally functional encodings implementation.
lorenzo-gomez-windhover Sep 3, 2024
72b3a6e
-Update Makefile
lorenzo-gomez-windhover Sep 4, 2024
016b1a8
-Update gitignore
lorenzo-gomez-windhover Sep 4, 2024
216756c
-Cleanup
lorenzo-gomez-windhover Sep 4, 2024
6736189
-Remove Ubuntu18 from github actions since it is not available anymore.
lorenzo-gomez-windhover Sep 4, 2024
5f2d57d
-Remove dead code
lorenzo-gomez-windhover Sep 4, 2024
f55ac39
-Cleanup
lorenzo-gomez-windhover Sep 4, 2024
615b7f1
-Cleanup
lorenzo-gomez-windhover Sep 4, 2024
f6cd03b
-Cleanup
lorenzo-gomez-windhover Sep 4, 2024
31f31c5
-Include unit test code in format checks.
lorenzo-gomez-windhover Sep 4, 2024
9aeeba7
-Update unit tests
lorenzo-gomez-windhover Sep 4, 2024
39b5b11
-Configure coveralls.io for CI
lorenzo-gomez-windhover Sep 4, 2024
af1b2df
-Configure coveralls.io for CI
lorenzo-gomez-windhover Sep 4, 2024
d1bbd70
-Configure coveralls.io for CI
lorenzo-gomez-windhover Sep 4, 2024
a6da24a
-Configure coveralls.io for CI
lorenzo-gomez-windhover Sep 4, 2024
e7a9912
-Configure coveralls.io for CI
lorenzo-gomez-windhover Sep 4, 2024
54f5393
-Configure coveralls.io for CI
lorenzo-gomez-windhover Sep 4, 2024
8361768
-Configure coveralls.io for CI
lorenzo-gomez-windhover Sep 4, 2024
f49be00
-Configure coveralls.io for CI
lorenzo-gomez-windhover Sep 4, 2024
1352632
-Update docs
lorenzo-gomez-windhover Sep 4, 2024
89455e2
-Update unit tests for new schema. WIP.
lorenzo-gomez-windhover Sep 4, 2024
b757e81
-Add followTargetSymbol. Useful for testing typedef'd types.
lorenzo-gomez-windhover Sep 5, 2024
82ec507
-Use CFE_ES_HousekeepingTlm_Payload for unit testing.
lorenzo-gomez-windhover Sep 5, 2024
7443457
-Update docs
lorenzo-gomez-windhover Sep 5, 2024
d8a025a
-Update docs
lorenzo-gomez-windhover Sep 6, 2024
c880916
-Extract ELF image data from 64-bit targets properly.
lorenzo-gomez-windhover Sep 6, 2024
6ac4fe1
-Update docs
lorenzo-gomez-windhover Sep 6, 2024
85c829b
-Update unit-test test files
lorenzo-gomez-windhover Sep 6, 2024
0403193
-Remove libdwarf from unit test code test file
lorenzo-gomez-windhover Sep 6, 2024
9ad54e0
-Remove dead code
lorenzo-gomez-windhover Sep 6, 2024
53b4341
-Remove dead code
lorenzo-gomez-windhover Sep 6, 2024
e5fbb07
-Add 32-bit make recipes.
lorenzo-gomez-windhover Sep 9, 2024
cd8da48
-Update 32-bit unit testing.
lorenzo-gomez-windhover Sep 9, 2024
52d8f8a
-Update docs
lorenzo-gomez-windhover Sep 9, 2024
b4df9e0
-Remove dead code
lorenzo-gomez-windhover Sep 9, 2024
e63d336
-Update Logger unit tests
lorenzo-gomez-windhover Sep 9, 2024
6be59f5
-Update unit tests
lorenzo-gomez-windhover Sep 9, 2024
7e4a883
-Update docs
lorenzo-gomez-windhover Sep 10, 2024
5e944cc
-Cleanup
lorenzo-gomez-windhover Sep 10, 2024
095647a
-Cleanup
lorenzo-gomez-windhover Sep 10, 2024
735d29e
-Cleanup
lorenzo-gomez-windhover Sep 10, 2024
092f457
-Add macro unit test.
lorenzo-gomez-windhover Sep 10, 2024
25b6bc4
-Create test files that comply with DWARF4 and DWARF5. Allows us to v…
lorenzo-gomez-windhover Sep 10, 2024
479b6d6
-Unit test DWARF4 and DWARF5. WIP.
lorenzo-gomez-windhover Sep 10, 2024
8002311
-Add DWARF4 testing to Dockerfile
lorenzo-gomez-windhover Sep 11, 2024
ebaf7ff
-Cleanup
lorenzo-gomez-windhover Sep 11, 2024
b230ef1
-Update docs
lorenzo-gomez-windhover Sep 11, 2024
ea76c12
-Update docs
lorenzo-gomez-windhover Sep 11, 2024
8bdbfa4
-Update Catch 2 due to issue on Ubuntu22:https://github.com/catchorg/…
lorenzo-gomez-windhover Sep 11, 2024
81bb553
-pathIndex handling for DWARF5. TODO:This changes for DWARF4, so add …
lorenzo-gomez-windhover Sep 12, 2024
d5bf6fa
-Handle DWARF dbg source files for DWARF4 and 5.
lorenzo-gomez-windhover Sep 13, 2024
d2e95fa
-Add group number as CLI argument. WIP.
lorenzo-gomez-windhover Sep 13, 2024
668968b
-Group number argument. Useful for getting DWARF data from multiple C…
lorenzo-gomez-windhover Sep 16, 2024
3512094
-Add unit tests for macros across multiple COMDAT groups.
lorenzo-gomez-windhover Sep 16, 2024
d4f9b28
-Cleanup
lorenzo-gomez-windhover Sep 16, 2024
1958a51
-Update docs
lorenzo-gomez-windhover Sep 16, 2024
ceefe40
-Update unit tests.
lorenzo-gomez-windhover Sep 16, 2024
b1f1466
-Move dwarf4 testing out of Makefile.
lorenzo-gomez-windhover Sep 17, 2024
f86de0f
-Update Dockerfile for Ubuntu22
lorenzo-gomez-windhover Sep 17, 2024
feb7e8f
-Update CI
lorenzo-gomez-windhover Sep 17, 2024
395d11c
-Update Dockerfiles for Ubuntu20 and Ubuntu22
lorenzo-gomez-windhover Sep 17, 2024
85ba705
-Update Makefile
lorenzo-gomez-windhover Sep 17, 2024
cdb7b1a
-Update CI
lorenzo-gomez-windhover Sep 17, 2024
8cf34df
-Update CI
lorenzo-gomez-windhover Sep 17, 2024
705bba1
-Test DWARF version in unit tests
lorenzo-gomez-windhover Sep 17, 2024
b46bf39
-Update docs
lorenzo-gomez-windhover Sep 17, 2024
418ba33
-Update docs
lorenzo-gomez-windhover Sep 17, 2024
5242b61
-Update docs
lorenzo-gomez-windhover Sep 17, 2024
f4997d1
-Update docs. WIP.
lorenzo-gomez-windhover Sep 17, 2024
9e3bfe3
-Update docs
lorenzo-gomez-windhover Sep 18, 2024
3f15cc0
-Cleanup
lorenzo-gomez-windhover Sep 18, 2024
4ea7916
-Cleanup
lorenzo-gomez-windhover Sep 18, 2024
55b4876
-Update docs.
lorenzo-gomez-windhover Sep 18, 2024
96a7d37
-Add unit tests for artifacts
lorenzo-gomez-windhover Sep 18, 2024
3a22ffc
-Cleanup
lorenzo-gomez-windhover Sep 18, 2024
f5af932
-Update test_file1
lorenzo-gomez-windhover Sep 18, 2024
a17990b
-Remove dead code
lorenzo-gomez-windhover Sep 18, 2024
130c6d8
-Update tests in Docker files
lorenzo-gomez-windhover Sep 18, 2024
b019c94
-Update docs
lorenzo-gomez-windhover Sep 18, 2024
006bd44
-Update docs
lorenzo-gomez-windhover Sep 18, 2024
e68832c
-Update docs
lorenzo-gomez-windhover Sep 18, 2024
870d817
-Update unit tests
lorenzo-gomez-windhover Sep 18, 2024
3e92982
-Add support for unions. WIP.
lorenzo-gomez-windhover Sep 18, 2024
b4a8232
-Add support for unions. WIP.
lorenzo-gomez-windhover Oct 10, 2024
2e6fa26
Merge branch 'develop' into union_support
lorenzo-gomez-windhover Oct 11, 2024
7a78c19
-Update CI to build Ubuntu20 first.
lorenzo-gomez-windhover Oct 11, 2024
477550a
-Update CI to build Ubuntu20 first.
lorenzo-gomez-windhover Oct 11, 2024
883c52f
-Format files
lorenzo-gomez-windhover Oct 11, 2024
9f39772
-Update union object used for unit tests
lorenzo-gomez-windhover Oct 11, 2024
9f84a30
-Add user to docker dev configs
lorenzo-gomez-windhover Oct 11, 2024
46e3f7f
-Add support for unions. WIP.
lorenzo-gomez-windhover Oct 11, 2024
d57f90c
-Minimally functional union support.
lorenzo-gomez-windhover Oct 11, 2024
112854f
-Remove dead code
lorenzo-gomez-windhover Oct 11, 2024
bdd9546
-Upgrade to C++17.
lorenzo-gomez-windhover Oct 11, 2024
4466531
-Update docs
lorenzo-gomez-windhover Oct 15, 2024
ed42dc5
-Remove duplicate recipes from Makefile
lorenzo-gomez-windhover Oct 15, 2024
343057a
-Handle default case in getdbgSourceFile
lorenzo-gomez-windhover Oct 15, 2024
cc2e951
-Update unit testing for union support
lorenzo-gomez-windhover Oct 15, 2024
7fd74e1
-Update unit testing for union support
lorenzo-gomez-windhover Oct 15, 2024
1f9e53b
-Update docs
lorenzo-gomez-windhover Oct 15, 2024
8ad0f46
-Update docs
lorenzo-gomez-windhover Oct 15, 2024
718ab5c
-Use std::optional for symbol encoding
lorenzo-gomez-windhover Oct 16, 2024
8050e31
-Add vscode config
lorenzo-gomez-windhover Oct 16, 2024
e2e7ec8
-Add tests for padding. Fixes https://github.com/WindhoverLabs/juicer…
lorenzo-gomez-windhover Oct 16, 2024
1f91f61
-Give root access to dev docker user
lorenzo-gomez-windhover Oct 16, 2024
3f6a0e7
-Use std::optional for getdbgSourceFile
lorenzo-gomez-windhover Oct 16, 2024
306e980
-Do not attempt to add padding for unions.
lorenzo-gomez-windhover Oct 16, 2024
5bb09aa
-Add warning message when field byte offsets do not exist
lorenzo-gomez-windhover Oct 16, 2024
ed160db
-Add warning message when field byte offsets do not exist
lorenzo-gomez-windhover Oct 16, 2024
4b03cbd
-Use git tag and latest commit as version value
lorenzo-gomez-windhover Oct 17, 2024
9558e7f
-Log warning when there is no DW_AT_name attribute
lorenzo-gomez-windhover Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@ jobs:
# push: false # Do not push the image
# tags: juicer:latest # Local tag for the built image

- name: Build Docker image For Ubuntu22
run: docker build --no-cache -t juicer:latest -f Dockerfile.ubuntu22 .

- name: Build Docker image For Ubuntu20
run: docker build --no-cache -t juicer:latest -f Dockerfile.ubuntu20 .

- name: Copy coverage report to host
run: docker image ls && img_id=$(docker create juicer:latest) && docker cp $img_id:/home/docker/juicer/coverage.gcov .

- name: publish to coveralls.io
run: wget https://github.com/coverallsapp/coverage-reporter/releases/download/v0.6.14/coveralls-linux && chmod a+x ./coveralls-linux && COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }} ./coveralls-linux

- name: Build Docker image For Ubuntu22
run: docker build --no-cache -t juicer:latest -f Dockerfile.ubuntu22 .


- name: Build Docker image For Ubuntu18
run: docker build --no-cache -t juicer:latest -f Dockerfile.ubuntu18 .

17 changes: 17 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/libdwarf"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}
87 changes: 87 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"configurations": [
{
"name": "x86",
"includePath": [
"/usr/include/libdwarf"
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"files.associations": {
"macro_test.h": "c",
"stdint.h": "c",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"chrono": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"list": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"set": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"variant": "cpp",
"bit": "cpp",
"compare": "cpp",
"concepts": "cpp",
"numbers": "cpp",
"semaphore": "cpp",
"stop_token": "cpp"
},
"editor.formatOnSave": true
}
5 changes: 5 additions & 0 deletions Dockerfile.ubuntu18
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ RUN ./juicer-ut "[main_test#20]"
RUN ./juicer-ut "[Module]"
RUN ./juicer-ut "[Symbol]"

RUN cd /home/docker/juicer && make coverage
#Useful for CI
RUN cd /home/docker/juicer && gcovr --filter /home/docker/juicer/src/ --object-directory /home/docker/juicer/build/ut_obj/ --xml coverage.gcov





8 changes: 8 additions & 0 deletions Dockerfile.ubuntu18.dev
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ RUN mkdir /home/docker/juicer
WORKDIR /home/docker/juicer



RUN useradd -ms /bin/bash juicer-dev
RUN usermod -aG sudo juicer-dev
RUN echo "juicer-dev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER juicer-dev


6 changes: 6 additions & 0 deletions Dockerfile.ubuntu20.dev
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ RUN apt-get install -y clang-format
RUN mkdir /home/docker
RUN mkdir /home/docker/juicer
WORKDIR /home/docker/juicer

RUN useradd -ms /bin/bash juicer-dev
RUN usermod -aG sudo juicer-dev
RUN echo "juicer-dev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER juicer-dev
6 changes: 6 additions & 0 deletions Dockerfile.ubuntu22.dev
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ RUN apt-get install -y gcovr
RUN mkdir /home/docker
RUN mkdir /home/docker/juicer
WORKDIR /home/docker/juicer

RUN useradd -ms /bin/bash juicer-dev
RUN usermod -aG sudo juicer-dev
RUN echo "juicer-dev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER juicer-dev
Binary file added Images/union_fields_tbl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/union_symbol_tbl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ UT_SRC_32 := $(wildcard $(UT_SRC_DIR)/test_file*.cpp)
UT_OBJ_32 := $(UT_SRC_32:$(UT_SRC_DIR)/test_file%.cpp=$(UT_OBJ_32BIT_DIR)/test_file%.o)
UT_OBJ_32 := $(UT_OBJ_32:$(UT_SRC_DIR)/test_file%.cpp=$(UT_OBJ_32BIT_DIR)/test_file%.o)

GIT_VERSION := "$(shell git describe --tags --abbrev=0)($(shell git rev-parse --short HEAD))"


# Set target flags
CPPFLAGS := -MMD -MP -std=c++14 -fmessage-length=0 $(INCLUDES)
CFLAGS := -Wall -g3
CPPFLAGS := -MMD -MP -std=c++17 -fmessage-length=0 $(INCLUDES)
CFLAGS := -Wall -g3 -DJUICER_VERSION=\"$(GIT_VERSION)\"
CFLAGS_32BIT := -Wall -g3 -m32
LDFLAGS := -Llib
LDLIBS := -lm -ldwarf -lsqlite3 -lelf -lcrypto
Expand Down Expand Up @@ -123,7 +125,6 @@ clean:
-include $(UT_OBJ:.o=.d)
-include $(OBJ:.o=.d)


docker-ubuntu18-build:
@sudo docker build --no-cache -t juicer:ubuntu18 -f Dockerfile.ubuntu18 .

Expand Down
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[![Run juicer tests](https://github.com/WindhoverLabs/juicer/actions/workflows/ci.yaml/badge.svg)](https://github.com/WindhoverLabs/juicer/actions/workflows/ci.yaml)
[![Coverage Status](https://coveralls.io/repos/github/WindhoverLabs/juicer/badge.svg?branch=unit_test_updates)](https://coveralls.io/github/WindhoverLabs/juicer?branch=unit_test_updates)
[![Coverage Status](https://coveralls.io/repos/github/WindhoverLabs/juicer/badge.svg?branch=unit_test_updates)](https://coveralls.io/github/WindhoverLabs/juicer?branch=develop)

# Table of Contents
1. [Dependencies](#dependencies)
Expand All @@ -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 <a name="dependencies"></a>
* `libdwarf-dev`
Expand Down Expand Up @@ -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).

Expand Down Expand Up @@ -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 <a name="union_support"></a>

Documentation updated on September 19, 2024
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:


![union_symbol](Images/union_symbol_tbl.png "symbols-table")

![union_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
15 changes: 8 additions & 7 deletions src/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Field::Field(Symbol& inSymbol, Symbol& inType)
: symbol{inSymbol}, // @suppress("Symbol is not resolved")
name{""},
byte_offset{0},
byte_offset{std::nullopt},
type{inType}, // @suppress("Symbol is not resolved")
dimensionList{},
little_endian{false},
Expand All @@ -22,7 +22,7 @@ Field::Field(Symbol& inSymbol, Symbol& inType)
type.getName().c_str(), dimensionList.toString(), little_endian ? "LE" : "BE");
}

Field::Field(Symbol& inSymbol, std::string& inName, uint32_t inByteOffset, Symbol& inType, DimensionList& inDimensionList, bool inLittleEndian,
Field::Field(Symbol& inSymbol, std::string& inName, std::optional<uint32_t> inByteOffset, Symbol& inType, DimensionList& inDimensionList, bool inLittleEndian,
uint32_t inBitSize, uint32_t inBitOffset)
: symbol{inSymbol}, // @suppress("Symbol is not resolved")
name{inName}, // @suppress("Symbol is not resolved")
Expand All @@ -41,7 +41,8 @@ Field::Field(Symbol& inSymbol, std::string& inName, uint32_t inByteOffset, Symbo
type.getName().c_str(), dimensionList.toString(), little_endian ? "LE" : "BE");
}

Field::Field(Symbol& inSymbol, std::string& inName, uint32_t inByteOffset, Symbol& inType, bool inLittleEndian, uint32_t inBitSize, uint32_t inBitOffset)
Field::Field(Symbol& inSymbol, std::string& inName, std::optional<uint32_t> inByteOffset, Symbol& inType, bool inLittleEndian, uint32_t inBitSize,
uint32_t inBitOffset)
: symbol{inSymbol}, // @suppress("Symbol is not resolved")
name{inName}, // @suppress("Symbol is not resolved")
byte_offset{inByteOffset},
Expand All @@ -60,13 +61,13 @@ Field::Field(Symbol& inSymbol, std::string& inName, uint32_t inByteOffset, Symbo
}
Field::~Field() {}

uint32_t Field::getByteOffset() const { return byte_offset; }
std::optional<uint32_t> Field::getByteOffset() const { return byte_offset; }

bool Field::isLittleEndian() const { return little_endian; }
bool Field::isLittleEndian() const { return little_endian; }

std::string& Field::getName() { return name; }
std::string& Field::getName() { return name; }

void Field::setName(const std::string& inName)
void Field::setName(const std::string& inName)
{
logger.logDebug("Field %s::%s renamed to %s.", symbol.getName().c_str(), name.c_str(), inName.c_str());

Expand Down
72 changes: 37 additions & 35 deletions src/Field.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <stdint.h>

#include <optional>
#include <vector>

#include "DimensionList.h"
Expand All @@ -30,50 +31,51 @@ class Field
{
public:
Field(Symbol &symbol, Symbol &type);
Field(Symbol &symbol, std::string &name, uint32_t byte_offset, Symbol &type, DimensionList &dimensionList, bool little_endian, uint32_t inBitSize = 0,
Field(Symbol &symbol, std::string &name, std::optional<uint32_t> byte_offset, Symbol &type, DimensionList &dimensionList, bool little_endian,
uint32_t inBitSize = 0, uint32_t inBitOffset = 0);
Field(Symbol &symbol, std::string &name, std::optional<uint32_t> byte_offset, Symbol &type, bool little_endian, uint32_t inBitSize = 0,
uint32_t inBitOffset = 0);
Field(Symbol &symbol, std::string &name, uint32_t byte_offset, Symbol &type, bool little_endian, uint32_t inBitSize = 0, uint32_t inBitOffset = 0);
virtual ~Field();
uint32_t getByteOffset() const;
bool isLittleEndian() const;
uint32_t getMultiplicity() const;
uint32_t getArraySize() const;
void setMultiplicity(uint32_t multiplicity);
std::string &getName();
void setName(const std::string &name);
Symbol &getSymbol() const;
Symbol &getType();
uint32_t getId(void) const;
void setId(uint32_t newId);
uint32_t getBitOffset() const;
void setBitOffset(uint32_t bitOffset);
uint32_t getBitSize() const;
void setBitSize(uint32_t bitSize);
bool isBitField(void);
DimensionList &getDimensionList();
bool isArray(void) const;
std::string getDimensionListStr();
std::optional<uint32_t> getByteOffset() const;
bool isLittleEndian() const;
uint32_t getMultiplicity() const;
uint32_t getArraySize() const;
void setMultiplicity(uint32_t multiplicity);
std::string &getName();
void setName(const std::string &name);
Symbol &getSymbol() const;
Symbol &getType();
uint32_t getId(void) const;
void setId(uint32_t newId);
uint32_t getBitOffset() const;
void setBitOffset(uint32_t bitOffset);
uint32_t getBitSize() const;
void setBitSize(uint32_t bitSize);
bool isBitField(void);
DimensionList &getDimensionList();
bool isArray(void) const;
std::string getDimensionListStr();

const std::string &getShortDescription() const { return short_description; }
const std::string &getShortDescription() const { return short_description; }

const std::string &getLongDescription() const { return long_description; }
const std::string &getLongDescription() const { return long_description; }

private:
Symbol &symbol;
std::string name;
uint32_t byte_offset;
Symbol &type;
DimensionList dimensionList;
bool little_endian;
Symbol &symbol;
std::string name;
std::optional<uint32_t> byte_offset{std::nullopt};
Symbol &type;
DimensionList dimensionList;
bool little_endian;
/*bit fields members.
* If this field is not bit-packed, then the bit_size and bit_offset are 0.*/
uint32_t bit_offset;
uint32_t bit_size;
Logger logger;
uint32_t id;
uint32_t bit_offset;
uint32_t bit_size;
Logger logger;
uint32_t id;

std::string short_description;
std::string long_description;
std::string short_description;
std::string long_description;
};

#endif /* FIELD_H_ */
Loading
Loading