Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Ignore defined functions from leak detection #21

Merged
merged 8 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Visual Leak Detector (VLD) Version 2.5.7

Change Log / Release Notes

2.5.9 (1 January 2023)
----------------------------
Enhancements:
+ Add option to ignore functions in vld.ini to skip checking for memory leaks.


2.5.8 (1 December 2021)
----------------------------
Bugs Fixed:
Expand Down
8 changes: 4 additions & 4 deletions setup/version.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

#define VLDVERSION L"2.5.8"
#define VERSION_NUMBER 2,5,8,0
#define VERSION_STRING "2.5.8.0"
#define VLDVERSION L"2.5.9"
#define VERSION_NUMBER 2,5,9,0
#define VERSION_STRING "2.5.9.0"
#define VERSION_COPYRIGHT "Copyright (C) 2005-2021"

#ifndef __FILE__
!define VLD_VERSION "2.5.8" // NSIS Script
!define VLD_VERSION "2.5.9" // NSIS Script
#endif
2 changes: 1 addition & 1 deletion setup/vld-setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Visual Leak Detector"
#define MyAppVersion "2.5.8"
#define MyAppVersion "2.5.9"
#define MyAppPublisher "VLD Team"
#define MyAppURL "http://vld.codeplex.com/"
#define MyAppRegKey "Software\Visual Leak Detector"
Expand Down
12 changes: 12 additions & 0 deletions src/callstack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ bool CallStack::isCrtStartupAlloc()
return true;
} else if (m_status & CALLSTACK_STATUS_NOTSTARTUPCRT) {
return false;
}

if (isIgnoreFunction(functionName)) {
return true;
}
}

Expand Down Expand Up @@ -571,6 +575,14 @@ UINT CallStack::isCrtStartupFunction( LPCWSTR functionName ) const
}

return NULL;
}

bool CallStack::isIgnoreFunction(LPCWSTR functionName) const
{
if (VisualLeakDetector::isFunctionIgnored(functionName)) {
return true;
}
return false;
}

bool CallStack::isInternalModule( const PWSTR filename ) const
Expand Down
1 change: 1 addition & 0 deletions src/callstack.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class CallStack

bool isInternalModule( const PWSTR filename ) const;
UINT isCrtStartupFunction( LPCWSTR functionName ) const;
bool isIgnoreFunction(LPCWSTR functionName) const;
LPCWSTR getFunctionName(SIZE_T programCounter, DWORD64& displacement64,
SYMBOL_INFO* functionInfo, CriticalSectionLocker<DbgHelp>& locker) const;
DWORD resolveFunction(SIZE_T programCounter, IMAGEHLP_LINEW64* sourceInfo, DWORD displacement,
Expand Down
6 changes: 5 additions & 1 deletion src/runtests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ ECHO ---------------------------------------------------------------------------
ECHO [ RUNNING ] %tests_path%\vld_main_test.exe
ECHO -------------------------------------------------------------------------------
!tests_path!\vld_main_test.exe --gtest_output="xml:!tests_path!\vld_main_test.exe.xml"
ECHO -------------------------------------------------------------------------------
ECHO -------------------------------------------------------------------------------
ECHO [ RUNNING ] %tests_path%\static_string_test.exe
ECHO -------------------------------------------------------------------------------
!tests_path!\static_string_test.exe --gtest_output="xml:!tests_path!\static_string_test.exe.xml"
ECHO -------------------------------------------------------------------------------
ECHO [ RUNNING ] %tests_path%\ignore_functions_test.exe
ECHO -------------------------------------------------------------------------------
!tests_path!\static_string_test.exe --gtest_output="xml:!tests_path!\ignore_functions_test.exe.xml"
ECHO -------------------------------------------------------------------------------
EXIT /b 0

:nodir
Expand Down
37 changes: 37 additions & 0 deletions src/tests/ignore_functions_test/ignore_functions_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// ignore_functions_test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "vld.h"
#include <string>


std::string GetOSVersion() {
std::string osVersion = "Windows";
return osVersion;
}

std::string SomeOtherString() {
std::string osVersion = "Windows";
return osVersion;
}

int main(int argc, char** argv)
{
static std::string const osVer = GetOSVersion();
static std::string const someOtherString = SomeOtherString();

int leaks = static_cast<int>(VLDGetLeaksCount());
if (0 != leaks)
{
(void)printf("!!! FAILED - Leaks detected: %i\n", leaks);
VLDReportLeaks();
}
else
{
(void)printf("PASSED\n");
}


return leaks;
}
Loading