fixed various warnings

This commit is contained in:
mrexodia 2015-11-20 00:30:36 +01:00
parent f20470890b
commit a71b10b697
7 changed files with 24 additions and 18 deletions

View File

@ -3,6 +3,9 @@
#include "GleeBug.h" #include "GleeBug.h"
//defines
#define GLEEBUG_HWBP_COUNT 4
namespace GleeBug namespace GleeBug
{ {
//forward declarations //forward declarations
@ -13,6 +16,9 @@ namespace GleeBug
enum class BreakpointType; enum class BreakpointType;
struct BreakpointInfo; struct BreakpointInfo;
//constants
const int HWBP_COUNT = GLEEBUG_HWBP_COUNT;
//key typedefs //key typedefs
typedef std::pair<BreakpointType, ptr> BreakpointKey; typedef std::pair<BreakpointType, ptr> BreakpointKey;

View File

@ -55,10 +55,10 @@ namespace GleeBug
return true; return true;
} }
bool ProcessInfo::GetFreeHardwareBreakpointSlot(HardwareBreakpointSlot & slot) bool ProcessInfo::GetFreeHardwareBreakpointSlot(HardwareBreakpointSlot & slot) const
{ {
//find a free hardware breakpoint slot //find a free hardware breakpoint slot
for (int i = 0; i < 4;i++) for (int i = 0; i < HWBP_COUNT; i++)
{ {
if (!hardwareBreakpoints[i].enabled) if (!hardwareBreakpoints[i].enabled)
{ {

View File

@ -9,7 +9,7 @@ namespace GleeBug
thread(nullptr), thread(nullptr),
systemBreakpoint(false) systemBreakpoint(false)
{ {
for (int i = 0; i < 4; i++) for (int i = 0; i < HWBP_COUNT; i++)
hardwareBreakpoints[i].enabled = false; hardwareBreakpoints[i].enabled = false;
} }
}; };

View File

@ -101,7 +101,7 @@ namespace GleeBug
\param [out] slot First free slot found, has no meaning when the function fails. \param [out] slot First free slot found, has no meaning when the function fails.
\return true if a free slot was found, false otherwise. \return true if a free slot was found, false otherwise.
*/ */
bool GetFreeHardwareBreakpointSlot(HardwareBreakpointSlot & slot); bool GetFreeHardwareBreakpointSlot(HardwareBreakpointSlot & slot) const;
/** /**
\brief Sets a hardware breakpoint. \brief Sets a hardware breakpoint.

View File

@ -32,9 +32,9 @@ namespace GleeBug
#pragma pack(1) #pragma pack(1)
struct DR7 struct DR7
{ {
BYTE DR7_MODE[4]; BYTE DR7_MODE[HWBP_COUNT];
BYTE DR7_TYPE[4]; BYTE DR7_TYPE[HWBP_COUNT];
BYTE DR7_SIZE[4]; BYTE DR7_SIZE[HWBP_COUNT];
}; };
static inline ptr dr7_ptr(const DR7 & dr7) static inline ptr dr7_ptr(const DR7 & dr7)

View File

@ -18,7 +18,7 @@ namespace GleeBug
STARTUPINFOW si; STARTUPINFOW si;
memset(&si, 0, sizeof(si)); memset(&si, 0, sizeof(si));
const wchar_t* szFileNameCreateProcess; const wchar_t* szFileNameCreateProcess;
wchar_t* szCommandLineCreateProcess = nullptr; wchar_t* szCommandLineCreateProcess;
wchar_t* szCreateWithCmdLine = nullptr; wchar_t* szCreateWithCmdLine = nullptr;
if (szCommandLine == nullptr || !wcslen(szCommandLine)) if (szCommandLine == nullptr || !wcslen(szCommandLine))
{ {
@ -50,12 +50,12 @@ namespace GleeBug
return result; return result;
} }
bool Debugger::Stop() bool Debugger::Stop() const
{ {
return !!TerminateProcess(_mainProcess.hProcess, 0); return !!TerminateProcess(_mainProcess.hProcess, 0);
} }
bool Debugger::Detach() bool Debugger::Detach() const
{ {
return !!DebugActiveProcessStop(_mainProcess.dwProcessId); return !!DebugActiveProcessStop(_mainProcess.dwProcessId);
} }

View File

@ -38,13 +38,13 @@ namespace GleeBug
\brief Stops the debuggee (terminate the process) \brief Stops the debuggee (terminate the process)
\return true if the debuggee was stopped correctly, false otherwise. \return true if the debuggee was stopped correctly, false otherwise.
*/ */
bool Stop(); bool Stop() const;
/** /**
\brief Detaches the debuggee. \brief Detaches the debuggee.
\return true if the debuggee was detached correctly, false otherwise. \return true if the debuggee was detached correctly, false otherwise.
*/ */
bool Detach(); bool Detach() const;
/** /**
\brief Run the debug loop (does not return until the debuggee is detached or terminated). \brief Run the debug loop (does not return until the debuggee is detached or terminated).
@ -226,26 +226,26 @@ namespace GleeBug
protected: //variables protected: //variables
PROCESS_INFORMATION _mainProcess; PROCESS_INFORMATION _mainProcess;
uint32 _continueStatus; uint32 _continueStatus = DBG_EXCEPTION_NOT_HANDLED;
bool _breakDebugger; bool _breakDebugger = false;
DEBUG_EVENT _debugEvent; DEBUG_EVENT _debugEvent;
ProcessMap _processes; ProcessMap _processes;
bool _isRunning; bool _isRunning = false;
/** /**
\brief The current process (can be null in some cases). \brief The current process (can be null in some cases).
*/ */
ProcessInfo* _process; ProcessInfo* _process = nullptr;
/** /**
\brief The current thread (can be null in some cases). Should be a copy of _process->thread. \brief The current thread (can be null in some cases). Should be a copy of _process->thread.
*/ */
ThreadInfo* _thread; ThreadInfo* _thread = nullptr;
/** /**
\brief The current thread registers (can be null in some cases). Should be a copy of _thread->registers. \brief The current thread registers (can be null in some cases). Should be a copy of _thread->registers.
*/ */
Registers* _registers; Registers* _registers = nullptr;
}; };
}; };