about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaulingMonkey <git@maulingmonkey.com>2017-07-13 10:04:43 -0700
committerMaulingMonkey <git@maulingmonkey.com>2017-07-13 10:04:43 -0700
commit8e10c4d55d5a21c879c01c57211579239f08d0b0 (patch)
tree0f4633dc22435e90a03c1c41cd4aec506039fa1d
parent5d5e67a9661897d3bc0862b27104c651caffd10b (diff)
downloadrust-8e10c4d55d5a21c879c01c57211579239f08d0b0.tar.gz
rust-8e10c4d55d5a21c879c01c57211579239f08d0b0.zip
Modify type names on MSVC to make strings and slices .natvis compatible.
-rw-r--r--src/etc/natvis/intrinsic.natvis24
-rw-r--r--src/librustc_trans/debuginfo/type_names.rs15
2 files changed, 35 insertions, 4 deletions
diff --git a/src/etc/natvis/intrinsic.natvis b/src/etc/natvis/intrinsic.natvis
new file mode 100644
index 00000000000..67be9769fb3
--- /dev/null
+++ b/src/etc/natvis/intrinsic.natvis
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
+  <Type Name="str">
+    <DisplayString>{data_ptr,[length]}</DisplayString>
+    <StringView>data_ptr,[length]</StringView>
+    <Expand>
+      <Item Name="[size]" ExcludeView="simple">length</Item>
+      <ArrayItems>
+        <Size>length</Size>
+        <ValuePointer>data_ptr</ValuePointer>
+      </ArrayItems>
+    </Expand>
+  </Type>
+  <Type Name="slice&lt;*&gt;">
+    <DisplayString>{{ length={length} }}</DisplayString>
+    <Expand>
+      <Item Name="[size]" ExcludeView="simple">length</Item>
+      <ArrayItems>
+        <Size>length</Size>
+        <ValuePointer>data_ptr</ValuePointer>
+      </ArrayItems>
+    </Expand>
+  </Type>
+</AutoVisualizer>
diff --git a/src/librustc_trans/debuginfo/type_names.rs b/src/librustc_trans/debuginfo/type_names.rs
index bfca4fec706..9ab5bc4a5a9 100644
--- a/src/librustc_trans/debuginfo/type_names.rs
+++ b/src/librustc_trans/debuginfo/type_names.rs
@@ -61,21 +61,27 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             output.push(')');
         },
         ty::TyRawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => {
-            output.push('*');
+            let is_like_msvc = cx.sess().target.target.options.is_like_msvc;
+
+            if !is_like_msvc {output.push('*');}
             match mutbl {
                 hir::MutImmutable => output.push_str("const "),
                 hir::MutMutable => output.push_str("mut "),
             }
 
             push_debuginfo_type_name(cx, inner_type, true, output);
+            if is_like_msvc {output.push('*');}
         },
         ty::TyRef(_, ty::TypeAndMut { ty: inner_type, mutbl }) => {
-            output.push('&');
+            let is_like_msvc = cx.sess().target.target.options.is_like_msvc;
+
+            if !is_like_msvc {output.push('&');}
             if mutbl == hir::MutMutable {
                 output.push_str("mut ");
             }
 
             push_debuginfo_type_name(cx, inner_type, true, output);
+            if is_like_msvc {output.push('*');}
         },
         ty::TyArray(inner_type, len) => {
             output.push('[');
@@ -84,9 +90,10 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             output.push(']');
         },
         ty::TySlice(inner_type) => {
-            output.push('[');
+            let is_like_msvc = cx.sess().target.target.options.is_like_msvc;
+            output.push_str(if is_like_msvc {"slice<"} else {"["});
             push_debuginfo_type_name(cx, inner_type, true, output);
-            output.push(']');
+            output.push(if is_like_msvc {'>'} else {']'});
         },
         ty::TyDynamic(ref trait_data, ..) => {
             if let Some(principal) = trait_data.principal() {