Skip to content

Commit

Permalink
logging: dictionary: Support unsigned integers
Browse files Browse the repository at this point in the history
Add unsigned integer support to the log parser.

This does not change the underlying log format,
it only allows the log parser to more accurately
read the log format.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
  • Loading branch information
glarsennordic authored and fabiobaltieri committed Oct 3, 2024
1 parent c0bb973 commit a459921
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions scripts/logging/dictionary/dictionary_parser/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ def __init__(self, database):

if database.is_tgt_64bit():
self.add_data_type(self.LONG, "q")
self.add_data_type(self.ULONG, "Q")
self.add_data_type(self.LONG_LONG, "q")
self.add_data_type(self.ULONG_LONG, "Q")
self.add_data_type(self.PTR, "Q")
else:
self.add_data_type(self.LONG, "i")
self.add_data_type(self.ULONG, "I")
self.add_data_type(self.LONG_LONG, "q")
self.add_data_type(self.ULONG_LONG, "Q")
self.add_data_type(self.PTR, "I")

self.add_data_type(self.INT, "i")
self.add_data_type(self.UINT, "I")
self.add_data_type(self.DOUBLE, "d")
self.add_data_type(self.LONG_DOUBLE, "d")

Expand Down
10 changes: 6 additions & 4 deletions scripts/logging/dictionary/dictionary_parser/log_parser_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,16 @@ def process_one_fmt_str(self, fmt_str, arg_list, string_tbl):
# intmax_t, size_t or ptrdiff_t
arg_data_type = DataTypes.LONG

elif fmt in ('c', 'd', 'i', 'o', 'u') or str.lower(fmt) == 'x':
elif fmt in ('c', 'd', 'i', 'o', 'u', 'x', 'X'):
unsigned = fmt in ('c', 'o', 'u', 'x', 'X')

if fmt_str[idx - 1] == 'l':
if fmt_str[idx - 2] == 'l':
arg_data_type = DataTypes.LONG_LONG
arg_data_type = DataTypes.ULONG_LONG if unsigned else DataTypes.LONG_LONG
else:
arg_data_type = DataTypes.LONG
arg_data_type = DataTypes.ULONG if unsigned else DataTypes.LONG
else:
arg_data_type = DataTypes.INT
arg_data_type = DataTypes.UINT if unsigned else DataTypes.INT

is_parsing = False
do_extract = True
Expand Down
10 changes: 6 additions & 4 deletions scripts/logging/dictionary/dictionary_parser/log_parser_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,16 @@ def process_one_fmt_str(self, fmt_str, arg_list, string_tbl):
# intmax_t, size_t or ptrdiff_t
arg_data_type = DataTypes.LONG

elif fmt in ('c', 'd', 'i', 'o', 'u') or str.lower(fmt) == 'x':
elif fmt in ('c', 'd', 'i', 'o', 'u', 'x', 'X'):
unsigned = fmt in ('c', 'o', 'u', 'x', 'X')

if fmt_str[idx - 1] == 'l':
if fmt_str[idx - 2] == 'l':
arg_data_type = DataTypes.LONG_LONG
arg_data_type = DataTypes.ULONG_LONG if unsigned else DataTypes.LONG_LONG
else:
arg_data_type = DataTypes.LONG
arg_data_type = DataTypes.ULONG if unsigned else DataTypes.LONG
else:
arg_data_type = DataTypes.INT
arg_data_type = DataTypes.UINT if unsigned else DataTypes.INT

is_parsing = False
do_extract = True
Expand Down

0 comments on commit a459921

Please sign in to comment.