@@ -182,11 +182,13 @@ def _decode_field_value(raw_bytes: bytes, type_name: str):
182182 is_int = any (kw in type_lower for kw in _INT_TYPE_KEYWORDS )
183183 if is_int and size <= 8 :
184184 val = int .from_bytes (raw_bytes , "little" )
185- # Signed check: type doesn't start with 'u'/'U' and doesn't contain 'uint'
185+ # Signed check: type doesn't start with 'u'/'U', doesn't contain 'uint',
186+ # and doesn't contain 'unsigned' (handles "long unsigned int" from DWARF)
186187 if (
187188 not type_name .startswith ("u" )
188189 and not type_name .startswith ("U" )
189190 and "uint" not in type_name
191+ and "unsigned" not in type_name
190192 ):
191193 max_signed = 1 << (size * 8 - 1 )
192194 if val >= max_signed :
@@ -796,6 +798,7 @@ def api_get_symbol_value():
796798 sym_info .get ("type" , "other" ) if isinstance (sym_info , dict ) else "function"
797799 )
798800 section = sym_info .get ("section" , "" ) if isinstance (sym_info , dict ) else ""
801+ c_type = sym_info .get ("c_type" ) if isinstance (sym_info , dict ) else None
799802 is_pointer = (
800803 sym_info .get ("is_pointer" , False ) if isinstance (sym_info , dict ) else False
801804 )
@@ -845,6 +848,14 @@ def api_get_symbol_value():
845848
846849 logger .info (f"[value] Total for '{ sym_name } ': { time .time () - t_start :.2f} s" )
847850
851+ # Decode scalar value from hex_data using c_type when no struct layout
852+ decoded_value = None
853+ if hex_data and c_type and not struct_layout and not is_pointer :
854+ raw = bytes .fromhex (hex_data )
855+ decoded_value = _decode_field_value (raw , c_type )
856+ if decoded_value is None :
857+ decoded_value = _decode_field_value_fallback (raw , c_type )
858+
848859 resp = {
849860 "success" : True ,
850861 "name" : sym_name ,
@@ -856,6 +867,10 @@ def api_get_symbol_value():
856867 "struct_layout" : struct_layout ,
857868 "gdb_values" : gdb_values ,
858869 }
870+ if c_type :
871+ resp ["c_type" ] = c_type
872+ if decoded_value is not None :
873+ resp ["decoded_value" ] = decoded_value
859874 if is_pointer :
860875 resp ["is_pointer" ] = True
861876 resp ["pointer_target" ] = pointer_target
@@ -897,6 +912,7 @@ def api_read_symbol_from_device():
897912 pointer_target = (
898913 sym_info .get ("pointer_target" ) if isinstance (sym_info , dict ) else None
899914 )
915+ c_type = sym_info .get ("c_type" ) if isinstance (sym_info , dict ) else None
900916 if size <= 0 :
901917 return jsonify (
902918 {"success" : False , "error" : f"Symbol '{ sym_name } ' has unknown size" }
@@ -934,6 +950,14 @@ def api_read_symbol_from_device():
934950 if struct_layout :
935951 gdb_values = _decode_struct_values (struct_layout , hex_data )
936952
953+ # Decode scalar value for non-struct, non-pointer types
954+ decoded_value = None
955+ if hex_data and c_type and not struct_layout and not is_pointer :
956+ raw = bytes .fromhex (hex_data )
957+ decoded_value = _decode_field_value (raw , c_type )
958+ if decoded_value is None :
959+ decoded_value = _decode_field_value_fallback (raw , c_type )
960+
937961 resp = {
938962 "success" : True ,
939963 "name" : sym_name ,
@@ -944,6 +968,10 @@ def api_read_symbol_from_device():
944968 "gdb_values" : gdb_values ,
945969 "source" : "device" ,
946970 }
971+ if c_type :
972+ resp ["c_type" ] = c_type
973+ if decoded_value is not None :
974+ resp ["decoded_value" ] = decoded_value
947975 if is_pointer :
948976 resp ["is_pointer" ] = True
949977 resp ["pointer_target" ] = pointer_target
@@ -1038,6 +1066,7 @@ def api_read_symbol_stream():
10381066 pointer_target = (
10391067 sym_info .get ("pointer_target" ) if isinstance (sym_info , dict ) else None
10401068 )
1069+ c_type = sym_info .get ("c_type" ) if isinstance (sym_info , dict ) else None
10411070 if size <= 0 :
10421071 return jsonify (
10431072 {"success" : False , "error" : f"Symbol '{ sym_name } ' has unknown size" }
@@ -1141,6 +1170,14 @@ def do_read_wrapper():
11411170 if struct_layout :
11421171 gdb_values = _decode_struct_values (struct_layout , hex_data )
11431172
1173+ # Decode scalar value for non-struct, non-pointer types
1174+ decoded_value = None
1175+ if hex_data and c_type and not struct_layout and not is_pointer :
1176+ raw = bytes .fromhex (hex_data )
1177+ decoded_value = _decode_field_value (raw , c_type )
1178+ if decoded_value is None :
1179+ decoded_value = _decode_field_value_fallback (raw , c_type )
1180+
11441181 resp = {
11451182 "type" : "result" ,
11461183 "success" : True ,
@@ -1152,6 +1189,10 @@ def do_read_wrapper():
11521189 "gdb_values" : gdb_values ,
11531190 "source" : "device" ,
11541191 }
1192+ if c_type :
1193+ resp ["c_type" ] = c_type
1194+ if decoded_value is not None :
1195+ resp ["decoded_value" ] = decoded_value
11551196 if is_pointer :
11561197 resp ["is_pointer" ] = True
11571198 resp ["pointer_target" ] = pointer_target
0 commit comments