Add a destructor for sos::GCHeap
authorMike McLaughlin <mikem@microsoft.com>
Thu, 18 Apr 2019 00:18:45 +0000 (17:18 -0700)
committerMike McLaughlin <mikem@microsoft.com>
Thu, 18 Apr 2019 19:10:44 +0000 (12:10 -0700)
Integer Conversion Issues from GCC

From PR https://github.com/dotnet/coreclr/pull/23934 in coreclr.

src/SOS/Strike/sos.cpp
src/SOS/Strike/sos.h
src/SOS/lldbplugin/services.cpp
src/SOS/lldbplugin/setsostidcommand.cpp

index bf84e1d8af2daaa797ee0fb653add50459fca026..4aacc2a2e774ccbebb4189e909776ef0238311cf 100644 (file)
@@ -795,6 +795,11 @@ namespace sos
         }
     }
 
+    GCHeap::~GCHeap()
+    {
+        delete [] mHeaps;
+    }
+
     ObjectIterator GCHeap::WalkHeap(TADDR start, TADDR stop) const
     {
         return ObjectIterator(mHeaps, mNumHeaps, start, stop);
index 80608dd371708aa3691297cb6b6861b74c4c1a91..4d154ef76f6aee7f08804eecac58b7e470b78452 100644 (file)
@@ -752,6 +752,8 @@ namespace sos
          */
         GCHeap();
 
+        ~GCHeap();
+
         /* Returns an ObjectIterator which allows you to walk the objects on the managed heap.
          * This ObjectIterator is valid for the duration of the GCHeap's lifetime.  Note that
          * if you specify an address at which you wish to start walking the heap it need
index 11b92b1952701b14a4b8a945a95ba2b02d7f3873..668b69473932d83610b21441c5057c5b5d5a36d6 100644 (file)
@@ -12,8 +12,8 @@
 
 #define CONVERT_FROM_SIGN_EXTENDED(offset) ((ULONG_PTR)(offset))
 
-ULONG g_currentThreadIndex = -1;
-ULONG g_currentThreadSystemId = -1;
+ULONG g_currentThreadIndex = (ULONG)-1;
+ULONG g_currentThreadSystemId = (ULONG)-1;
 char *g_coreclrDirectory = nullptr;
 char *g_pluginModuleDirectory = nullptr;
 
@@ -616,7 +616,7 @@ LLDBServices::Disassemble(
 
     size = instruction.GetByteSize();
     data = instruction.GetData(target);
-    for (int i = 0; i < size && bufferSize > 0; i++)
+    for (ULONG i = 0; i < size && bufferSize > 0; i++)
     {
         byte = data.GetUnsignedInt8(error, i);
         if (error.Fail())
@@ -718,7 +718,7 @@ LLDBServices::GetContextStackTrace(
     }
 
     frame = thread.GetFrameAtIndex(0);
-    for (int i = 0; i < thread.GetNumFrames(); i++)
+    for (uint32_t i = 0; i < thread.GetNumFrames(); i++)
     {
         if (!frame.IsValid() || (cFrames > framesSize) || ((char *)currentContext > ((char *)frameContexts + frameContextsSize)))
         {
@@ -1382,7 +1382,7 @@ LLDBServices::GetCurrentThreadId(
 
     // This is allow the a valid current TID to be returned to 
     // workaround a bug in lldb on core dumps.
-    if (g_currentThreadIndex != -1)
+    if (g_currentThreadIndex != (ULONG)-1)
     {
         *id = g_currentThreadIndex;
         return S_OK;
@@ -1428,7 +1428,7 @@ LLDBServices::GetCurrentThreadSystemId(
 
     // This is allow the a valid current TID to be returned to 
     // workaround a bug in lldb on core dumps.
-    if (g_currentThreadSystemId != -1)
+    if (g_currentThreadSystemId != (ULONG)-1)
     {
         *sysId = g_currentThreadSystemId;
         return S_OK;
@@ -1462,7 +1462,7 @@ LLDBServices::GetThreadIdBySystemId(
 
     // If we have a "fake" thread OS (system) id and a fake thread index,
     // we need to return fake thread index.
-    if (g_currentThreadSystemId == sysId && g_currentThreadIndex != -1)
+    if (g_currentThreadSystemId == sysId && g_currentThreadIndex != (ULONG)-1)
     {
         id = g_currentThreadIndex;
     }
@@ -1510,7 +1510,7 @@ LLDBServices::GetThreadContextById(
 
     // If we have a "fake" thread OS (system) id and a fake thread index,
     // use the fake thread index to get the context.
-    if (g_currentThreadSystemId == threadID && g_currentThreadIndex != -1)
+    if (g_currentThreadSystemId == threadID && g_currentThreadIndex != (ULONG)-1)
     {
         thread = process.GetThreadByIndexID(g_currentThreadIndex);
     }
index 392682e583e2457331db27456967aedaf0bdced2..9b40a357c60d28d73fe1b029987b87878d624ec0 100644 (file)
@@ -23,7 +23,7 @@ public:
     {
         if (arguments == nullptr || arguments[0] == nullptr)
         {
-            if (g_currentThreadSystemId == -1 || g_currentThreadIndex == -1)
+            if (g_currentThreadSystemId == (ULONG)-1 || g_currentThreadIndex == (ULONG)-1)
             {
                 result.Printf("sos OS tid not mapped\n");
             }
@@ -33,8 +33,8 @@ public:
             }
         }
         else if (strcmp(arguments[0], "-clear") == 0) {
-            g_currentThreadIndex = -1;
-            g_currentThreadSystemId = -1;
+            g_currentThreadIndex = (ULONG)-1;
+            g_currentThreadSystemId = (ULONG)-1;
             result.Printf("Cleared sos OS tid/index\n");
         }
         else if (arguments[1] == nullptr)