bug 1408502 - embed natvis info for Gecko types in our PDB files. r?build
MSVC supports XML natvis files for pretty-printing types in the debugger:
https://docs.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects
The gecko.natvis in this commit is from vlad's github repo:
https://github.com/mozilla/moz-dev-contrib/blob/master/windows/Gecko.natvis
This change simply makes the linker embed this natvis file into xul.pdb
when linking xul.dll, so that Microsoft's debuggers can more usefully
display Gecko data types. With this file in-tree it should be easy for
developers to make additions or improvements.
MozReview-Commit-ID: JZhxyaDODC1
new file mode 100644
--- /dev/null
+++ b/toolkit/library/gecko.natvis
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
+
+ <!-- Mozilla Gecko Visualizers -->
+
+ <!-- nsTArray -->
+ <Type Name="nsTArray<*>">
+ <DisplayString Condition="mHdr->mLength == 0 && mHdr->mCapacity == 0">empty</DisplayString>
+ <DisplayString Condition="mHdr->mLength == mHdr->mCapacity">size = {mHdr->mLength}</DisplayString>
+ <DisplayString>size = {mHdr->mLength}, capacity = {mHdr->mCapacity}</DisplayString>
+ <Expand>
+ <ArrayItems Condition="mHdr->mLength > 0">
+ <Size>mHdr->mLength</Size>
+ <ValuePointer>($T1*)(mHdr + 1)</ValuePointer>
+ </ArrayItems>
+ </Expand>
+ </Type>
+
+ <!-- refcounts -->
+ <Type Name="nsAutoRefCnt">
+ <DisplayString>{mValue}</DisplayString>
+ </Type>
+
+ <Type Name="nsCycleCollectingAutoRefCnt">
+ <!-- this value needs to be updated if NS_NUMBER_OF_FLAGS_IN_REFCNT in xpcom/glue/nsISupportsImpl.h changes -->
+ <DisplayString>{mValue >> 2}</DisplayString>
+ <Expand>
+ <Synthetic Name="In Purple Buffer"><DisplayString>{mValue & 1 != 0}</DisplayString></Synthetic>
+ <Synthetic Name="Is Purple"><DisplayString>{mValue & 2 != 0}</DisplayString></Synthetic>
+ </Expand>
+ </Type>
+
+ <Type Name="mozilla::ThreadSafeAutoRefCnt">
+ <DisplayString>{mValue.mValue._My_val}</DisplayString>
+ </Type>
+
+ <!-- smart pointer/refcount pointer things -->
+ <Type Name="nsRefPtr<*>">
+ <AlternativeType Name="nsCOMPtr<*>" />
+ <AlternativeType Name="nsAutoPtr<*>" />
+ <AlternativeType Name="mozilla::WebGLRefPtr<*>" />
+
+ <DisplayString Condition="mRawPtr == 0">NULL</DisplayString>
+ <DisplayString>{*($T1*)mRawPtr}</DisplayString>
+ <Expand>
+ <ExpandedItem>($T1*)mRawPtr</ExpandedItem>
+ </Expand>
+ </Type>
+
+ <!-- strings -->
+ <Type Name="nsACString">
+ <AlternativeType Name="nsACString_internal" />
+ <AlternativeType Name="nsCString" />
+ <AlternativeType Name="nsLiteralCString" />
+
+ <DisplayString>{mData,s}</DisplayString>
+ <StringView>mData,s</StringView>
+ <Expand>
+ <Item Name="Length">mLength</Item>
+ <Item Name="Flags">mFlags</Item>
+ </Expand>
+ </Type>
+
+ <Type Name="nsAString">
+ <AlternativeType Name="nsAString_internal" />
+ <AlternativeType Name="nsString" />
+ <AlternativeType Name="nsLiteralString" />
+
+ <DisplayString>{mData,su}</DisplayString>
+ <StringView>mData,su</StringView>
+ <Expand>
+ <Item Name="Length">mLength</Item>
+ <Item Name="Flags">mFlags</Item>
+ </Expand>
+ </Type>
+
+ <!-- rects, points, etc. -->
+ <Type Name="mozilla::gfx::BaseRect<*,*,*,*,*>">
+ <AlternativeType Name="mozilla::gfx::Rect" />
+ <DisplayString>x={x}, y={y}, width={width}, height={height}</DisplayString>
+ </Type>
+
+ <Type Name="mozilla::gfx::BaseSize<*,*>">
+ <AlternativeType Name="mozilla::gfx::Size" />
+ <AlternativeType Name="nsIntSize" />
+ <DisplayString>width={width}, height={height}</DisplayString>
+ </Type>
+
+ <Type Name="mozilla::gfx::BasePoint<*,*>">
+ <AlternativeType Name="mozilla::gfx::Point" />
+ <DisplayString>x={x}, y={y}</DisplayString>
+ </Type>
+
+ <Type Name="mozilla::gfx::Matrix4x4">
+ <AlternativeType Name="gfx3DMatrix" />
+ <DisplayString Condition="(_11==_22==_33==_44==1) && (_12==_13==_14==_21==_23==_24==_31==_32==_34==_41==_42==_43==0)">[Identity]</DisplayString>
+ <DisplayString Condition="(_11==_22==_33==_44==1) && (_12==_13==_14==_21==_23==_24==_31==_32==_34==0)">[Translate: ({_41}, {_42}, {_43})]</DisplayString>
+ <DisplayString Condition="_44==1 && (_12==_13==_14==_21==_23==_24==_31==_32==_34==_41==_42==_43==0)">[Scale: ({_11}, {_22}, {_33})]</DisplayString>
+ <DisplayString>[4x4 Matrix]</DisplayString>
+
+ <Expand>
+ <Synthetic Name="R1"><DisplayString>[{_11}, {_12}, {_13}, {_14}]</DisplayString></Synthetic>
+ <Synthetic Name="R2"><DisplayString>[{_21}, {_22}, {_23}, {_24}]</DisplayString></Synthetic>
+ <Synthetic Name="R3"><DisplayString>[{_31}, {_32}, {_33}, {_34}]</DisplayString></Synthetic>
+ <Synthetic Name="R4"><DisplayString>[{_41}, {_42}, {_43}, {_44}]</DisplayString></Synthetic>
+ </Expand>
+ </Type>
+
+ <!-- JS types -->
+ <Type Name="JS::Handle<*>">
+ <DisplayString Condition="ptr == 0">NULL</DisplayString>
+ <DisplayString>{*($T1*)ptr}</DisplayString>
+ <Expand>
+ <ExpandedItem>($T1*)ptr</ExpandedItem>
+ </Expand>
+ </Type>
+
+
+</AutoVisualizer>
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -72,16 +72,21 @@ def Libxul(name):
OS_LIBS += ['atomic']
# This option should go away in bug 1290972, but we need to wait until
# Rust 1.12 has been released.
# We're also linking against libresolv to solve bug 1367932.
if CONFIG['OS_ARCH'] == 'Darwin':
LDFLAGS += ['-Wl,-no_compact_unwind,-lresolv']
+ # This actually wants to check that the linker is link.exe, but we don't have a
+ # config variable for that currently.
+ if CONFIG['MOZ_DEBUG_SYMBOLS'] and CONFIG['CC_TYPE'] in ('msvc', 'clang-cl'):
+ LDFLAGS += ['-NATVIS:%s/toolkit/library/gecko.natvis' % TOPSRCDIR]
+
Libxul('xul')
FORCE_STATIC_LIB = True
STATIC_LIBRARY_NAME = 'xul_s'
SOURCES += [
'StaticXULComponentsStart.cpp',