Skip to content

Commit be454f0

Browse files
committed
Change char type in debuginfo to DW_ATE_UTF
Rust previously encoded the `char` type as DW_ATE_unsigned_char. The more appropriate encoding is DW_ATE_UTF. Clang uses this same debug encoding for char32_t. This fixes the display of `char` types in Windows debuggers as well as LLDB.
1 parent c651ba8 commit be454f0

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const DW_ATE_signed: c_uint = 0x05;
8787
#[allow(non_upper_case_globals)]
8888
const DW_ATE_unsigned: c_uint = 0x07;
8989
#[allow(non_upper_case_globals)]
90-
const DW_ATE_unsigned_char: c_uint = 0x08;
90+
const DW_ATE_UTF: c_uint = 0x10;
9191

9292
pub const UNKNOWN_LINE_NUMBER: c_uint = 0;
9393
pub const UNKNOWN_COLUMN_NUMBER: c_uint = 0;
@@ -933,7 +933,7 @@ fn basic_type_metadata<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'l
933933
ty::Never => ("!", DW_ATE_unsigned),
934934
ty::Tuple(elements) if elements.is_empty() => ("()", DW_ATE_unsigned),
935935
ty::Bool => ("bool", DW_ATE_boolean),
936-
ty::Char => ("char", DW_ATE_unsigned_char),
936+
ty::Char => ("char", DW_ATE_UTF),
937937
ty::Int(int_ty) if cpp_like_debuginfo => (int_ty.msvc_basic_name(), DW_ATE_signed),
938938
ty::Uint(uint_ty) if cpp_like_debuginfo => (uint_ty.msvc_basic_name(), DW_ATE_unsigned),
939939
ty::Float(float_ty) if cpp_like_debuginfo => (float_ty.msvc_basic_name(), DW_ATE_float),

src/test/debuginfo/basic-types.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@
104104
// cdb-check:b : false [Type: bool]
105105
// cdb-command:dx i
106106
// cdb-check:i : -1 [Type: [...]]
107-
// The variable 'c' doesn't appear for some reason...
107+
// cdb-command:dx c
108+
// cdb-check:c : 0x61 'a' [Type: char32_t]
108109
// cdb-command:dx i8
109110
// cdb-check:i8 : 68 [Type: char]
110111
// cdb-command:dx i16

src/test/debuginfo/borrowed-basic.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
// gdb-check:$2 = -1
1515

1616
// gdb-command:print *char_ref
17-
// gdbg-check:$3 = 97
18-
// gdbr-check:$3 = 97 'a'
17+
// gdb-check:$3 = 97
1918

2019
// gdb-command:print *i8_ref
2120
// gdbg-check:$4 = 68 'D'

src/test/debuginfo/borrowed-unique-basic.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
// gdb-check:$2 = -1
1717

1818
// gdb-command:print *char_ref
19-
// gdbg-check:$3 = 97
20-
// gdbr-check:$3 = 97 'a'
19+
// gdb-check:$3 = 97
2120

2221
// gdb-command:print/d *i8_ref
2322
// gdb-check:$4 = 68

0 commit comments

Comments
 (0)