forked from mozy/mordor
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
68 changed files
with
3,066 additions
and
833 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,77 @@ | |||
; Add to C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\autoexp.dat in the [Visualizer] section | |||
; The visualizer isn't perfect - it uses ; instead of :, and , instead of / between path segments | |||
; Also, it doesn't perform any encoding | |||
|
|||
Mordor::URI{ | |||
preview ( | |||
#( | |||
#if ($e.m_schemeDefined) ( #( | |||
#if (($e.m_scheme._Myres) < ($e.m_scheme._BUF_SIZE)) ( [$e.m_scheme._Bx._Buf,sb] ) #else ( [$e.m_scheme._Bx._Ptr,sb] ), | |||
";") | |||
) #else ( "" ), | |||
#if ($e.authority.m_hostDefined) ( #("//", $e.authority) ) #else ( "" ), | |||
#if ($e.path.type == ABSOLUTE || $e.path.segments._Myfirst != $e.path.segments._Mylast) ( $e.path ) #else ( "" ), | |||
#if ($e.m_queryDefined) ( #( | |||
"?", | |||
#if (($e.m_query._Myres) < ($e.m_query._BUF_SIZE)) ( [$e.m_query._Bx._Buf,sb] ) #else ( [$e.m_query._Bx._Ptr,sb] )) | |||
) #else ( "" ), | |||
#if ($e.m_fragmentDefined) ( #( | |||
"#", | |||
#if (($e.m_fragment._Myres) < ($e.m_fragment._BUF_SIZE)) ( [$e.m_fragment._Bx._Buf,sb] ) #else ( [$e.m_fragment._Bx._Ptr,sb] )) | |||
) #else ( "" ) | |||
) | |||
) | |||
children ( | |||
#( | |||
#if ($e.m_schemeDefined) ( #(scheme: $e.m_scheme) ) #else ( #array(expr: 0, size: 0) ), | |||
#if ($e.authority.m_hostDefined) ( #(authority: $e.authority) ) #else ( #array(expr: 0, size: 0) ), | |||
#if ($e.path.type == ABSOLUTE || $e.path.segments._Myfirst != $e.path.segments._Mylast) ( #(path: $e.path) ) #else ( #array(expr: 0, size: 0) ), | |||
#if ($e.m_queryDefined) ( #(query: $e.m_query) ) #else ( #array(expr: 0, size: 0) ), | |||
#if ($e.m_fragmentDefined) ( #(fragment: $e.m_fragment) ) #else ( #array(expr: 0, size: 0) ), | |||
#(Actual Members: [$e,!]) | |||
) | |||
) | |||
} | |||
|
|||
Mordor::URI::Authority{ | |||
preview ( | |||
#( | |||
#if ($e.m_userinfoDefined) ( #( #if (($e.m_userinfo._Myres) < ($e.m_userinfo._BUF_SIZE)) ( [$e.m_userinfo._Bx._Buf,sb] ) #else ( [$e.m_userinfo._Bx._Ptr,sb] ), "@") ) #else ( "" ), | |||
#if ($e.m_hostDefined) ( #if (($e.m_host._Myres) < ($e.m_host._BUF_SIZE)) ( [$e.m_host._Bx._Buf,sb] ) #else ( [$e.m_host._Bx._Ptr,sb] ) ) #else ( "" ), | |||
#if ($e.m_portDefined) ( #( ";", $e.m_port) ) #else ( "" ) | |||
) | |||
) | |||
children ( | |||
#( | |||
#if ($e.m_userinfoDefined) ( #( userinfo: $e.m_userinfo) ) #else ( #array(expr: 0, size: 0) ), | |||
#if ($e.m_hostDefined) ( #( host: $e.m_host) ) #else ( #array(expr: 0, size: 0) ), | |||
#if ($e.m_portDefined) ( #( port: $e.m_port) ) #else ( #array(expr: 0, size: 0) ), | |||
#(Actual Members: [$e,!]) | |||
) | |||
) | |||
} | |||
|
|||
Mordor::URI::Path{ | |||
preview ( | |||
#if ($e.type == RELATIVE && $e.segments._Myfirst == $e.segments._Mylast) ( | |||
"" | |||
) #else ( | |||
#( | |||
#if ($e.type == ABSOLUTE) ( | |||
"/" | |||
) #else ( | |||
"" | |||
), | |||
#array( | |||
expr: | |||
#if ((($e.segments._Myfirst[$i])._Myres) < (($e.segments._Myfirst[$i])._BUF_SIZE)) ( | |||
[($e.segments._Myfirst[$i])._Bx._Buf,sb] | |||
) #else ( | |||
[($e.segments._Myfirst[$i])._Bx._Ptr,sb] | |||
), | |||
size: $e.segments._Mylast - $e.segments._Myfirst | |||
) | |||
) | |||
) | |||
) | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,102 @@ | |||
// Copyright (c) 2009 - Mozy, Inc. | |||
|
|||
#include "mordor/predef.h" | |||
|
|||
#include <iostream> | |||
|
|||
#include <DbgHelp.h> | |||
|
|||
#include "mordor/config.h" | |||
#include "mordor/streams/buffered.h" | |||
#include "mordor/streams/std.h" | |||
|
|||
using namespace Mordor; | |||
|
|||
int main(int argc, const char *argv[]) | |||
{ | |||
if (argc < 3) { | |||
std::cerr << "Usage: " << argv[0] << " <symbolpath> <binary>..." << std::endl | |||
<< " Look for backtrace addresses on stdin, and attempt to convert them to" << std::endl | |||
<< " symbols of the given binaries." << std::endl << std::endl; | |||
return 1; | |||
} | |||
|
|||
std::vector<DWORD64> loadedModules; | |||
try { | |||
Config::loadFromEnvironment(); | |||
// Re-init symbols (it got initted statically in exception.cpp) with | |||
// a symbol search path | |||
if (!SymCleanup(GetCurrentProcess())) | |||
MORDOR_THROW_EXCEPTION_FROM_LAST_ERROR_API("SymCleanup"); | |||
if (!SymInitialize(GetCurrentProcess(), argv[1], FALSE)) | |||
MORDOR_THROW_EXCEPTION_FROM_LAST_ERROR_API("SymInitialize"); | |||
|
|||
// Load up the specified modules in their default load location | |||
// Does *not* currently handle ASLR (basically, it would need to | |||
// do two passes through the log, and calculate the actual load address | |||
// of a module based on where the (limited) symbols that are in the | |||
// file ended up; or, use a minidump to aid the process) | |||
for (int i = 2; i < argc; ++i) { | |||
DWORD64 baseAddress = | |||
SymLoadModule64(GetCurrentProcess(), NULL, argv[i], NULL, 0, 0); | |||
if (baseAddress == 0) { | |||
if (GetLastError() == ERROR_SUCCESS) | |||
continue; | |||
MORDOR_THROW_EXCEPTION_FROM_LAST_ERROR_API("SymLoadModule64"); | |||
} | |||
loadedModules.push_back(baseAddress); | |||
} | |||
char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME - 1]; | |||
SYMBOL_INFO *symbol = (SYMBOL_INFO*)buf; | |||
symbol->SizeOfStruct = sizeof(SYMBOL_INFO); | |||
symbol->MaxNameLen = MAX_SYM_NAME; | |||
DWORD64 displacement64 = 0; | |||
|
|||
Stream::ptr stream(new StdinStream()); | |||
stream.reset(new BufferedStream(stream)); | |||
StdoutStream output; | |||
std::string line; | |||
do { | |||
line = stream->getDelimited('\n', true); | |||
std::string copy(line); | |||
if (copy.size() >= 35 && | |||
strncmp(copy.c_str(), "[struct Mordor::tag_backtrace *] = ", 35) | |||
== 0) | |||
copy = copy.substr(35); | |||
char *end; | |||
DWORD64 address = strtoull(copy.c_str(), &end, 16); | |||
if ( (end - copy.c_str()) == 8 || (end - copy.c_str()) == 16) { | |||
if (SymFromAddr(GetCurrentProcess(), address, &displacement64, symbol)) { | |||
std::ostringstream os; | |||
if (copy != line) | |||
os << "[struct Mordor::tag_backtrace *] = "; | |||
os << copy.substr(0, (end - copy.c_str())) << ": " | |||
<< symbol->Name << "+" << displacement64; | |||
IMAGEHLP_LINE64 line; | |||
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); | |||
DWORD displacement = 0; | |||
if (SymGetLineFromAddr64(GetCurrentProcess(), | |||
address, &displacement, &line)) { | |||
std::cout << ": " << line.FileName << "(" | |||
<< line.LineNumber << ")+" << displacement; | |||
} | |||
os << std::endl; | |||
std::string newline = os.str(); | |||
output.write(newline.c_str(), newline.size()); | |||
} else { | |||
output.write(line.c_str(), line.size()); | |||
} | |||
} else { | |||
output.write(line.c_str(), line.size()); | |||
} | |||
} while (!line.empty() && line.back() == '\n'); | |||
} catch (...) { | |||
std::cerr << boost::current_exception_diagnostic_information() << std::endl; | |||
for (size_t i = 0; i < loadedModules.size(); ++i) | |||
SymUnloadModule64(GetCurrentProcess(), loadedModules[i]); | |||
return 2; | |||
} | |||
for (size_t i = 0; i < loadedModules.size(); ++i) | |||
SymUnloadModule64(GetCurrentProcess(), loadedModules[i]); | |||
return 0; | |||
} |
Oops, something went wrong.