1
0
Fork 0

DBG: Fix small inconsistencies (capitals, comments)

This commit is contained in:
Nukem 2015-06-09 18:07:05 -04:00
parent 3192bc4cdc
commit dc45a8b270
11 changed files with 34 additions and 45 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>

View File

@ -60,8 +60,7 @@ void BookmarkDelRange(uint Start, uint End)
// 0x00000000 - 0xFFFFFFFF // 0x00000000 - 0xFFFFFFFF
if(Start == 0 && End == ~0) if(Start == 0 && End == ~0)
{ {
EXCLUSIVE_ACQUIRE(LockBookmarks); BookmarkClear();
bookmarks.clear();
} }
else else
{ {

View File

@ -87,8 +87,7 @@ void CommentDelRange(uint Start, uint End)
// 0x00000000 - 0xFFFFFFFF // 0x00000000 - 0xFFFFFFFF
if(Start == 0 && End == ~0) if(Start == 0 && End == ~0)
{ {
EXCLUSIVE_ACQUIRE(LockComments); CommentClear();
comments.clear();
} }
else else
{ {

View File

@ -1178,7 +1178,7 @@ DWORD WINAPI threadDebugLoop(void* lpParameter)
ModClear(); ModClear();
ThreadClear(); ThreadClear();
GuiSetDebugState(stopped); GuiSetDebugState(stopped);
dputs("debugging stopped!"); dputs("Debugging stopped!");
varset("$hp", (uint)0, true); varset("$hp", (uint)0, true);
varset("$pid", (uint)0, true); varset("$pid", (uint)0, true);
unlock(WAITID_STOP); //we are done unlock(WAITID_STOP); //we are done
@ -1235,7 +1235,7 @@ bool cbEnableAllHardwareBreakpoints(const BREAKPOINT* bp)
BpSetTitanType(bp->addr, BPHARDWARE, titantype); BpSetTitanType(bp->addr, BPHARDWARE, titantype);
if(!BpEnable(bp->addr, BPHARDWARE, true) or !SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint)) if(!BpEnable(bp->addr, BPHARDWARE, true) or !SetHardwareBreakPoint(bp->addr, drx, TITANGETTYPE(bp->titantype), TITANGETSIZE(bp->titantype), (void*)cbHardwareBreakpoint))
{ {
dprintf("could not enable hardware breakpoint "fhex"\n", bp->addr); dprintf("Could not enable hardware breakpoint "fhex"\n", bp->addr);
return false; return false;
} }
return true; return true;

View File

@ -147,7 +147,7 @@ CMDRESULT cbDebugSetBPXOptions(int argc, char* argv[])
{ {
if(argc < 2) if(argc < 2)
{ {
dputs("not enough arguments!"); dputs("Not enough arguments!");
return STATUS_ERROR; return STATUS_ERROR;
} }
DWORD type = 0; DWORD type = 0;
@ -186,7 +186,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
{ {
if(argc < 2) if(argc < 2)
{ {
dputs("not enough arguments!"); dputs("Not enough arguments!");
return STATUS_ERROR; return STATUS_ERROR;
} }
char argaddr[deflen] = ""; char argaddr[deflen] = "";
@ -490,7 +490,7 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[])
{ {
if(argc < 2) if(argc < 2)
{ {
dputs("not enough arguments!"); dputs("Not enough arguments!");
return STATUS_ERROR; return STATUS_ERROR;
} }
uint addr; uint addr;
@ -630,7 +630,7 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
case 'x': case 'x':
break; break;
default: default:
dputs("invalid type, assuming 'x'"); dputs("Invalid type, assuming 'x'");
break; break;
} }
} }
@ -685,12 +685,12 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[])
} }
if(!BpNew(addr, true, false, 0, BPHARDWARE, titantype, 0)) if(!BpNew(addr, true, false, 0, BPHARDWARE, titantype, 0))
{ {
dputs("error setting hardware breakpoint (bpnew)!"); dputs("Error setting hardware breakpoint (bpnew)!");
return STATUS_ERROR; return STATUS_ERROR;
} }
if(!SetHardwareBreakPoint(addr, drx, type, titsize, (void*)cbHardwareBreakpoint)) if(!SetHardwareBreakPoint(addr, drx, type, titsize, (void*)cbHardwareBreakpoint))
{ {
dputs("error setting hardware breakpoint (TitanEngine)!"); dputs("Error setting hardware breakpoint (TitanEngine)!");
return STATUS_ERROR; return STATUS_ERROR;
} }
dprintf("Hardware breakpoint at "fhex" set!\n", addr); dprintf("Hardware breakpoint at "fhex" set!\n", addr);
@ -808,7 +808,7 @@ CMDRESULT cbDebugMemset(int argc, char* argv[])
uint base = MemFindBaseAddr(addr, &size, true); uint base = MemFindBaseAddr(addr, &size, true);
if(!base) if(!base)
{ {
dputs("invalid address specified"); dputs("Invalid address specified");
return STATUS_ERROR; return STATUS_ERROR;
} }
uint diff = addr - base; uint diff = addr - base;
@ -971,7 +971,7 @@ CMDRESULT cbDebugDump(int argc, char* argv[])
{ {
if(argc < 2) if(argc < 2)
{ {
dputs("not enough arguments!"); dputs("Not enough arguments!");
return STATUS_ERROR; return STATUS_ERROR;
} }
duint addr = 0; duint addr = 0;
@ -1023,7 +1023,7 @@ CMDRESULT cbDebugBpDll(int argc, char* argv[])
{ {
if(argc < 2) if(argc < 2)
{ {
dputs("not enough arguments!"); dputs("Not enough arguments!");
return STATUS_ERROR; return STATUS_ERROR;
} }
DWORD type = UE_ON_LIB_ALL; DWORD type = UE_ON_LIB_ALL;

View File

@ -103,8 +103,7 @@ void FunctionDelRange(uint Start, uint End)
// 0x00000000 - 0xFFFFFFFF // 0x00000000 - 0xFFFFFFFF
if(Start == 0 && End == ~0) if(Start == 0 && End == ~0)
{ {
EXCLUSIVE_ACQUIRE(LockFunctions); FunctionClear();
functions.clear();
} }
else else
{ {

View File

@ -23,14 +23,14 @@ const unsigned char* FunctionAnalysis::TranslateAddress(uint addr)
void FunctionAnalysis::Analyse() void FunctionAnalysis::Analyse()
{ {
dputs("analysis started..."); dputs("Starting analysis...");
DWORD ticks = GetTickCount(); DWORD ticks = GetTickCount();
PopulateReferences(); PopulateReferences();
dprintf("%u called functions populated\n", _functions.size()); dprintf("%u called functions populated\n", _functions.size());
AnalyseFunctions(); AnalyseFunctions();
dprintf("analysis finished in %ums!\n", GetTickCount() - ticks); dprintf("Analysis finished in %ums!\n", GetTickCount() - ticks);
} }
void FunctionAnalysis::SetMarkers() void FunctionAnalysis::SetMarkers()
@ -82,7 +82,6 @@ void FunctionAnalysis::AnalyseFunctions()
if(i < _functions.size() - 1) if(i < _functions.size() - 1)
maxaddr = _functions[i + 1].start; maxaddr = _functions[i + 1].start;
//dprintf("analysing function %p-??? maxaddr: %p\n", function.start, maxaddr);
uint end = FindFunctionEnd(function.start, maxaddr); uint end = FindFunctionEnd(function.start, maxaddr);
if(end) if(end)
{ {

View File

@ -1398,7 +1398,7 @@ CMDRESULT cbInstrFunctionList(int argc, char* argv[])
FunctionEnum(0, &cbsize); FunctionEnum(0, &cbsize);
if(!cbsize) if(!cbsize)
{ {
dputs("no functions"); dputs("No functions");
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
Memory<FUNCTIONSINFO*> functions(cbsize, "cbInstrFunctionList:functions"); Memory<FUNCTIONSINFO*> functions(cbsize, "cbInstrFunctionList:functions");

View File

@ -111,8 +111,7 @@ void LabelDelRange(uint Start, uint End)
// 0x00000000 - 0xFFFFFFFF // 0x00000000 - 0xFFFFFFFF
if(Start == 0 && End == ~0) if(Start == 0 && End == ~0)
{ {
EXCLUSIVE_ACQUIRE(LockLabels); LabelClear();
labels.clear();
} }
else else
{ {

View File

@ -203,7 +203,7 @@ bool MemRead(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfBytes
readBase += readSize; readBase += readSize;
Size -= readSize; Size -= readSize;
readSize = (Size > PAGE_SIZE) ? PAGE_SIZE : Size; readSize = min(PAGE_SIZE, Size);
} }
} }
@ -258,7 +258,7 @@ bool MemWrite(void* BaseAddress, void* Buffer, SIZE_T Size, SIZE_T* NumberOfByte
writeBase += writeSize; writeBase += writeSize;
Size -= writeSize; Size -= writeSize;
writeSize = (Size > PAGE_SIZE) ? PAGE_SIZE : Size; writeSize = min(PAGE_SIZE, Size);
} }
} }

View File

@ -8,31 +8,31 @@ std::map<Range, MODINFO, RangeCompare> modinfo;
bool ModLoad(uint Base, uint Size, const char* FullPath) bool ModLoad(uint Base, uint Size, const char* FullPath)
{ {
//
// Handle a new module being loaded // Handle a new module being loaded
//
// TODO: Do loaded modules always require a path?
if(!Base || !Size || !FullPath) if(!Base || !Size || !FullPath)
return false; return false;
MODINFO info;
// Copy the module path in the struct // Copy the module path in the struct
MODINFO info;
strcpy_s(info.path, FullPath); strcpy_s(info.path, FullPath);
// Break the module path into a directory and file name // Break the module path into a directory and file name
char dir[MAX_PATH] = ""; char dir[MAX_PATH];
char file[MAX_MODULE_SIZE] = ""; char file[MAX_MODULE_SIZE];
strcpy_s(dir, FullPath); strcpy_s(dir, FullPath);
_strlwr(dir); _strlwr(dir);
char* fileStart = strrchr(dir, '\\');
if(fileStart)
{ {
strcpy_s(file, fileStart + 1); char* fileStart = strrchr(dir, '\\');
*fileStart = '\0';
if(fileStart)
{
strcpy_s(file, fileStart + 1);
fileStart[0] = '\0';
}
} }
//calculate module hash from full file name // Calculate module hash from full file name
info.hash = ModHashFromName(file); info.hash = ModHashFromName(file);
// Copy the extension into the module struct // Copy the extension into the module struct
@ -46,10 +46,8 @@ bool ModLoad(uint Base, uint Size, const char* FullPath)
} }
} }
// Copy the name to the module struct // Copy information to struct
strcpy_s(info.name, file); strcpy_s(info.name, file);
// Module base address/size
info.base = Base; info.base = Base;
info.size = Size; info.size = Size;
@ -172,9 +170,7 @@ uint ModBaseFromAddr(uint Address)
uint ModHashFromAddr(uint Address) uint ModHashFromAddr(uint Address)
{ {
//
// Returns a unique hash from a virtual address // Returns a unique hash from a virtual address
//
SHARED_ACQUIRE(LockModules); SHARED_ACQUIRE(LockModules);
auto module = ModInfoFromAddr(Address); auto module = ModInfoFromAddr(Address);
@ -187,9 +183,7 @@ uint ModHashFromAddr(uint Address)
uint ModHashFromName(const char* Module) uint ModHashFromName(const char* Module)
{ {
//
// return MODINFO.hash (based on the name) // return MODINFO.hash (based on the name)
//
if(!Module || Module[0] == '\0') if(!Module || Module[0] == '\0')
return 0; return 0;