Skip to content
Permalink
Browse files

vc_crt_fix & leak detector improvements

  • Loading branch information...
alabuzhev committed Jul 1, 2017
1 parent a7a1742 commit 25e334230d58bab114b5ef62d149b91c7276e05b
Showing with 229 additions and 85 deletions.
  1. +6 −0 far/changelog
  2. +0 −1 far/main.cpp
  3. +14 −12 far/memcheck.cpp
  4. +0 −2 far/memcheck.hpp
  5. +1 −1 far/vbuild.m4
  6. +208 −69 far/vc_crt_fix_impl.cpp
@@ -1,3 +1,9 @@
drkns 01.07.2017 13:08:48 +0000 - build 4981

1. Стабы в vc_crt_fix_impl.cpp заменены более-менее рабочими версиями.

2. Уточнение работы leak-детектора.

drkns 28.06.2017 19:02:42 +0000 - build 4980

1. Ошибка отображения информации о заблокированном файле.
@@ -815,7 +815,6 @@ static int mainImpl(const range<wchar_t**>& Args)

static int wmain_seh(int Argc, wchar_t *Argv[])
{
atexit(PrintMemory);
#if defined(SYSLOG)
atexit(PrintSysLogStat);
#endif
@@ -113,6 +113,8 @@ static int& GetMarker(MEMINFO* Info)
return *reinterpret_cast<int*>(reinterpret_cast<char*>(Info)+Info->Size-sizeof(EndMarker));
}

void PrintMemory();

static void RegisterBlock(MEMINFO *block)
{
if (!MonitoringEnabled)
@@ -122,6 +124,13 @@ static void RegisterBlock(MEMINFO *block)
InitializeCriticalSection(&CS);
EnterCriticalSection(&CS);

static auto AtExitSet = false;
if (!AtExitSet)
{
atexit(PrintMemory);
AtExitSet = true;
}

block->prev = LastMemBlock;
block->next = nullptr;

@@ -265,8 +274,7 @@ static string FindStr(const void* Data, size_t Size)

void PrintMemory()
{
bool MonitoringState = MonitoringEnabled;
MonitoringEnabled = false;
const auto MonitoringState = std::exchange(MonitoringEnabled, false);

if (CallNewDeleteVector || CallNewDeleteScalar || AllocatedMemoryBlocks || AllocatedMemorySize)
{
@@ -291,9 +299,10 @@ void PrintMemory()
for(auto i = FirstMemBlock.next; i; i = i->next)
{
const auto BlockSize = i->Size - sizeof(MEMINFO) - sizeof(EndMarker);
Message = concat(encoding::ansi::get_chars(FormatLine(i->File, i->Line, i->Function, i->AllocationType, BlockSize)),
L"\nData: "_sv, BlobToHexWString(ToUser(i), std::min(BlockSize, size_t(16)), L' '),
L"\nhr: "_sv, FindStr(ToUser(i), BlockSize), L'\n');
const auto UserAddress = ToUser(i);
Message = concat(str(UserAddress), L", "_sv, encoding::ansi::get_chars(FormatLine(i->File, i->Line, i->Function, i->AllocationType, BlockSize)),
L"\nData: "_sv, BlobToHexWString(UserAddress, std::min(BlockSize, size_t(16)), L' '),
L"\nhr: "_sv, FindStr(UserAddress, BlockSize), L'\n');

std::wcerr << Message;
OutputDebugString(Message.data());
@@ -380,10 +389,3 @@ wchar_t* DuplicateString(const wchar_t * str, const char* Function, const char*
}

#endif

void PrintMemory()
{
#ifdef MEMCHECK
memcheck::PrintMemory();
#endif
}
@@ -49,6 +49,4 @@ void operator delete[](void* block, const char* Function, const char* File, int
#define new new(__FUNCTION__, __FILE__, __LINE__)
#endif

void PrintMemory();

#endif // MEMCHECK_HPP_3DC127D2_3D5C_4E0C_BFDD_6CE23AE099DB
@@ -1 +1 @@
m4_define(BUILD,4980)m4_dnl
m4_define(BUILD,4981)m4_dnl
Oops, something went wrong.

0 comments on commit 25e3342

Please sign in to comment.
You can’t perform that action at this time.