mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-07 07:49:31 +03:00
Fix VS solution
This commit is contained in:
parent
090ef45120
commit
38f139b0a5
5 changed files with 48 additions and 163 deletions
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
|
@ -478,6 +478,10 @@
|
|||
<ClCompile Include="..\..\src\page.c" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_arenas.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_help.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_options.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_settings.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_stats.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_utils.cpp" />
|
||||
<ClCompile Include="..\..\src\random.c" />
|
||||
<ClCompile Include="..\..\src\os.c" />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\alloc.c">
|
||||
|
@ -62,13 +62,25 @@
|
|||
<Filter>Sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg.cpp">
|
||||
<Filter>Sources</Filter>
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_arenas.cpp">
|
||||
<Filter>Sources</Filter>
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_help.cpp">
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_options.cpp">
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_settings.cpp">
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_stats.cpp">
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_utils.cpp">
|
||||
<Filter>Sources</Filter>
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -116,5 +128,8 @@
|
|||
<Filter Include="Sources">
|
||||
<UniqueIdentifier>{461c78ef-04b0-44d1-a0ca-7d488abaa592}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Sources\Windbg">
|
||||
<UniqueIdentifier>{bf629ef1-9605-4d6a-9099-79a29f1289ec}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
|
@ -510,6 +510,10 @@
|
|||
<ClCompile Include="..\..\src\page.c" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_arenas.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_help.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_options.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_settings.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_stats.cpp" />
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_utils.cpp" />
|
||||
<ClCompile Include="..\..\src\random.c" />
|
||||
<ClCompile Include="..\..\src\stats.c" />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\alloc.c">
|
||||
|
@ -62,13 +62,25 @@
|
|||
<Filter>Sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg.cpp">
|
||||
<Filter>Sources</Filter>
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_arenas.cpp">
|
||||
<Filter>Sources</Filter>
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_utils.cpp">
|
||||
<Filter>Sources</Filter>
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_help.cpp">
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_options.cpp">
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_settings.cpp">
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\prim\windows\windbg\mimalloc_windbg_stats.cpp">
|
||||
<Filter>Sources\Windbg</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -116,5 +128,8 @@
|
|||
<Filter Include="Sources">
|
||||
<UniqueIdentifier>{94b40bdc-a741-45dd-81aa-c05fabcd2970}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Sources\Windbg">
|
||||
<UniqueIdentifier>{b1d8c8ac-e35b-46e1-adbc-5ad0acf195f2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,153 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
Copyright (c) Microsoft Research
|
||||
This is free software; you can redistribute it and/or modify it under the
|
||||
terms of the MIT license. A copy of the license can be found in the file
|
||||
"LICENSE" at the root of this distribution.
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "mimalloc_windbg_heap.h"
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#include "mimalloc_internal.h"
|
||||
#include "mimalloc_windbg_utils.h"
|
||||
|
||||
/*
|
||||
Command: !mi_dump_current_thread_heap
|
||||
|
||||
- Retrieves the global _mi_heap_default symbol.
|
||||
- Reads the mi_heap_t structure from the debuggee memory.
|
||||
- Outputs key details of the current thread's heap (thread ID, page count, segment count).
|
||||
- Provides a rich link to trigger a detailed dump of the heap.
|
||||
- This command is critical for diagnosing per-thread memory allocation behavior.
|
||||
*/
|
||||
extern "C" __declspec(dllexport) HRESULT CALLBACK mi_dump_current_thread_heap(PDEBUG_CLIENT client, PCSTR args) {
|
||||
UNREFERENCED_PARAMETER(args);
|
||||
UNREFERENCED_PARAMETER(client);
|
||||
|
||||
ULONG64 heapAddress = 0;
|
||||
HRESULT hr = GetSymbolOffset("_mi_heap_default", heapAddress);
|
||||
if (FAILED(hr)) {
|
||||
g_DebugControl->Output(DEBUG_OUTPUT_ERROR, "Failed to locate _mi_heap_default\n");
|
||||
return hr;
|
||||
}
|
||||
|
||||
mi_heap_t heap = {0};
|
||||
hr = ReadMemory(heapAddress, &heap, sizeof(heap));
|
||||
if (FAILED(hr)) {
|
||||
g_DebugControl->Output(DEBUG_OUTPUT_ERROR, "Failed to read heap structure at 0x%llx\n", heapAddress);
|
||||
return hr;
|
||||
}
|
||||
|
||||
g_DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Heap for thread %u:\n Page Count: %u, Segment Count: %u\n", heap.thread_id, heap.page_count, heap.segment_count);
|
||||
|
||||
char link[128];
|
||||
snprintf(link, sizeof(link), "!mi.DumpHeap 0x%llx", heapAddress);
|
||||
PrintLink(link, "Click here to dump detailed heap info", heapAddress);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
Command: !mi_dump_all_thread_heaps
|
||||
|
||||
- Retrieves the _mi_heaps array and the heap count (_mi_heap_count).
|
||||
- Iterates over each thread's heap, reading its mi_heap_t structure.
|
||||
- Outputs a summary for each heap along with rich links for detailed inspection.
|
||||
- Useful for understanding the distribution of memory usage across threads.
|
||||
*/
|
||||
extern "C" __declspec(dllexport) HRESULT CALLBACK mi_dump_all_thread_heaps(PDEBUG_CLIENT client, PCSTR args) {
|
||||
UNREFERENCED_PARAMETER(args);
|
||||
UNREFERENCED_PARAMETER(client);
|
||||
|
||||
ULONG64 heapsAddress = 0;
|
||||
HRESULT hr = GetSymbolOffset("_mi_heaps", heapsAddress);
|
||||
if (FAILED(hr)) {
|
||||
g_DebugControl->Output(DEBUG_OUTPUT_ERROR, "Failed to locate _mi_heaps\n");
|
||||
return hr;
|
||||
}
|
||||
|
||||
ULONG64 heapCountAddress = 0;
|
||||
hr = GetSymbolOffset("_mi_heap_count", heapCountAddress);
|
||||
if (FAILED(hr)) {
|
||||
g_DebugControl->Output(DEBUG_OUTPUT_ERROR, "Failed to locate _mi_heap_count\n");
|
||||
return hr;
|
||||
}
|
||||
|
||||
size_t heapCount = 0;
|
||||
hr = ReadMemory(heapCountAddress, &heapCount, sizeof(heapCount));
|
||||
if (FAILED(hr)) {
|
||||
g_DebugControl->Output(DEBUG_OUTPUT_ERROR, "Failed to read heap count\n");
|
||||
return hr;
|
||||
}
|
||||
|
||||
std::vector<mi_heap_t*> heaps(heapCount);
|
||||
hr = ReadMemory(heapsAddress, heaps.data(), heapCount * sizeof(mi_heap_t*));
|
||||
if (FAILED(hr)) {
|
||||
g_DebugControl->Output(DEBUG_OUTPUT_ERROR, "Failed to read heaps array\n");
|
||||
return hr;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < heapCount; i++) {
|
||||
ULONG64 heapAddr = (ULONG64)heaps[i];
|
||||
mi_heap_t heap = {0};
|
||||
hr = ReadMemory(heapAddr, &heap, sizeof(heap));
|
||||
if (FAILED(hr))
|
||||
continue;
|
||||
|
||||
g_DebugControl->Output(DEBUG_OUTPUT_NORMAL, "\nHeap for thread %u:\n Page Count: %u, Segment Count: %u\n", heap.thread_id, heap.page_count, heap.segment_count);
|
||||
|
||||
char link[128];
|
||||
snprintf(link, sizeof(link), "!mi.DumpHeap 0x%llx", heapAddr);
|
||||
PrintLink(link, "Click here for detailed heap info", heapAddr);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
Command: !mi_dump_aggregated_thread_heap_stats
|
||||
|
||||
- Aggregates statistics from all thread heaps.
|
||||
- Sums the page count and segment count for all heaps.
|
||||
- Outputs an aggregated view that helps identify global memory usage patterns and potential imbalances.
|
||||
*/
|
||||
extern "C" __declspec(dllexport) HRESULT CALLBACK mi_dump_aggregated_thread_heap_stats(PDEBUG_CLIENT client, PCSTR args) {
|
||||
UNREFERENCED_PARAMETER(args);
|
||||
UNREFERENCED_PARAMETER(client);
|
||||
|
||||
ULONG64 heapsAddress = 0;
|
||||
HRESULT hr = GetSymbolOffset("_mi_heaps", heapsAddress);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
ULONG64 heapCountAddress = 0;
|
||||
hr = GetSymbolOffset("_mi_heap_count", heapCountAddress);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
size_t heapCount = 0;
|
||||
hr = ReadMemory(heapCountAddress, &heapCount, sizeof(heapCount));
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
std::vector<mi_heap_t*> heaps(heapCount);
|
||||
hr = ReadMemory(heapsAddress, heaps.data(), heapCount * sizeof(mi_heap_t*));
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
size_t totalPages = 0;
|
||||
size_t totalSegments = 0;
|
||||
for (size_t i = 0; i < heapCount; i++) {
|
||||
ULONG64 heapAddr = (ULONG64)heaps[i];
|
||||
mi_heap_t heap = {0};
|
||||
hr = ReadMemory(heapAddr, &heap, sizeof(heap));
|
||||
if (FAILED(hr))
|
||||
continue;
|
||||
totalPages += heap.page_count;
|
||||
totalSegments += heap.segment_count;
|
||||
}
|
||||
|
||||
g_DebugControl->Output(DEBUG_OUTPUT_NORMAL, "Aggregated Heap Statistics:\n Total Heaps: %zu\n Total Pages: %zu, Total Segments: %zu\n", heapCount, totalPages, totalSegments);
|
||||
|
||||
return S_OK;
|
||||
}
|
Loading…
Add table
Reference in a new issue