DBG: added 'srcline' exprfunc
This commit is contained in:
parent
88784b357a
commit
e8c2e5c572
|
@ -1,5 +1,6 @@
|
|||
#include "expressionfunctions.h"
|
||||
#include "threading.h"
|
||||
#include "exprfunc.h"
|
||||
|
||||
std::unordered_map<String, ExpressionFunctions::Function> ExpressionFunctions::mFunctions;
|
||||
|
||||
|
@ -33,7 +34,11 @@ static bool RegisterEasy(const String & name, duint(*cbFunction)(Ts...))
|
|||
|
||||
void ExpressionFunctions::Init()
|
||||
{
|
||||
//TODO: register some functions
|
||||
//TODO: register more functions
|
||||
using namespace Exprfunc;
|
||||
|
||||
//undocumented
|
||||
RegisterEasy("srcline", srcline);
|
||||
}
|
||||
|
||||
bool ExpressionFunctions::Register(const String & name, int argc, CBEXPRESSIONFUNCTION cbFunction)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include "exprfunc.h"
|
||||
#include "symbolinfo.h"
|
||||
|
||||
namespace Exprfunc
|
||||
{
|
||||
duint srcline(duint addr)
|
||||
{
|
||||
int line = 0;
|
||||
DWORD displacement = 0;
|
||||
if(!SymGetSourceLine(addr, nullptr, &line, &displacement) || displacement)
|
||||
return 0;
|
||||
return line;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "_global.h"
|
||||
|
||||
namespace Exprfunc
|
||||
{
|
||||
duint srcline(duint addr);
|
||||
}
|
|
@ -262,7 +262,7 @@ String SymGetSymbolicName(duint Address)
|
|||
return StringUtils::sprintf("<%s>", label);
|
||||
}
|
||||
|
||||
bool SymGetSourceLine(duint Cip, char* FileName, int* Line)
|
||||
bool SymGetSourceLine(duint Cip, char* FileName, int* Line, DWORD* disp)
|
||||
{
|
||||
IMAGEHLP_LINEW64 lineInfo;
|
||||
memset(&lineInfo, 0, sizeof(IMAGEHLP_LINE64));
|
||||
|
@ -275,6 +275,9 @@ bool SymGetSourceLine(duint Cip, char* FileName, int* Line)
|
|||
if(!SymGetLineFromAddrW64(fdProcessInfo->hProcess, Cip, &displacement, &lineInfo))
|
||||
return false;
|
||||
|
||||
if(disp)
|
||||
*disp = displacement;
|
||||
|
||||
String NewFile = StringUtils::Utf16ToUtf8(lineInfo.FileName);
|
||||
|
||||
// Copy line number if requested
|
||||
|
|
|
@ -18,6 +18,6 @@ String SymGetSymbolicName(duint Address);
|
|||
\param [out] nLine Line number. Can be null.
|
||||
\return true if it succeeds, false if it fails.
|
||||
*/
|
||||
bool SymGetSourceLine(duint Cip, char* FileName, int* Line);
|
||||
bool SymGetSourceLine(duint Cip, char* FileName, int* Line, DWORD* displacement = nullptr);
|
||||
|
||||
#endif // _SYMBOLINFO_H
|
|
@ -50,6 +50,7 @@
|
|||
<ClCompile Include="disasm_fast.cpp" />
|
||||
<ClCompile Include="disasm_helper.cpp" />
|
||||
<ClCompile Include="expressionfunctions.cpp" />
|
||||
<ClCompile Include="exprfunc.cpp" />
|
||||
<ClCompile Include="handles.cpp" />
|
||||
<ClCompile Include="error.cpp" />
|
||||
<ClCompile Include="exception.cpp" />
|
||||
|
@ -143,6 +144,7 @@
|
|||
<ClInclude Include="disasm_helper.h" />
|
||||
<ClInclude Include="dynamicmem.h" />
|
||||
<ClInclude Include="expressionfunctions.h" />
|
||||
<ClInclude Include="exprfunc.h" />
|
||||
<ClInclude Include="handles.h" />
|
||||
<ClInclude Include="error.h" />
|
||||
<ClInclude Include="exception.h" />
|
||||
|
|
|
@ -344,6 +344,9 @@
|
|||
<ClCompile Include="analysis\xrefsanalysis.cpp">
|
||||
<Filter>Source Files\Analysis</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="exprfunc.cpp">
|
||||
<Filter>Source Files\Debugger Core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="x64_dbg.h">
|
||||
|
@ -778,5 +781,8 @@
|
|||
<ClInclude Include="analysis\xrefsanalysis.h">
|
||||
<Filter>Header Files\Analysis</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="exprfunc.h">
|
||||
<Filter>Header Files\Debugger Core</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue