| From 13006b6efec2f865f2cef484458b3329158090c7 Mon Sep 17 00:00:00 2001 |
| From: Jon Turney <jon.turney@dronecode.org.uk> |
| Date: Sun, 3 Aug 2014 23:44:28 +0100 |
| Subject: [PATCH 13/29] Add symsrv_convert |
| |
| - Add symsrv_convert from http://hg.mozilla.org/users/tmielczarek_mozilla.com/fetch-win32-symbols/ |
| - Add building symsrv_convert to .gyp file |
| - Fix compilation with MSVS 2013 |
| - NOMINMAX should not be needed as that comes from target_defaults |
| |
| v2: |
| Update symsrv_convert.cc for |
| MSSymbolServerConverter::LocateAndConvertSymbolFile() changes |
| |
| This has been needed for a few years... |
| |
| Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk> |
| --- |
| src/common/windows/common_windows.gyp | 2 +- |
| src/common/windows/pdb_source_line_writer.cc | 6 +++ |
| .../converter/ms_symbol_server_converter.cc | 2 +- |
| .../converter/ms_symbol_server_converter.gyp | 13 +++++ |
| .../windows/converter/ms_symbol_server_converter.h | 4 +- |
| src/tools/windows/converter/symsrv_convert.cc | 61 ++++++++++++++++++++++ |
| 6 files changed, 84 insertions(+), 4 deletions(-) |
| mode change 100644 => 100755 src/common/windows/pdb_source_line_writer.cc |
| mode change 100644 => 100755 src/tools/windows/converter/ms_symbol_server_converter.cc |
| mode change 100644 => 100755 src/tools/windows/converter/ms_symbol_server_converter.h |
| create mode 100644 src/tools/windows/converter/symsrv_convert.cc |
| |
| diff --git a/src/common/windows/common_windows.gyp b/src/common/windows/common_windows.gyp |
| index c98333a3..9e542cbe 100644 |
| --- a/src/common/windows/common_windows.gyp |
| +++ b/src/common/windows/common_windows.gyp |
| @@ -37,7 +37,7 @@ |
| 'all_dependent_settings': { |
| 'include_dirs': [ |
| '<(DEPTH)', |
| - '$(VSInstallDir)/DIA SDK/include', |
| + '"$(VSInstallDir)/DIA SDK/include"', |
| ], |
| 'msvs_settings': { |
| 'VCLinkerTool': { |
| diff --git a/src/common/windows/pdb_source_line_writer.cc b/src/common/windows/pdb_source_line_writer.cc |
| old mode 100644 |
| new mode 100755 |
| index dace8860..a7e4bbd2 |
| --- a/src/common/windows/pdb_source_line_writer.cc |
| +++ b/src/common/windows/pdb_source_line_writer.cc |
| @@ -27,6 +27,12 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| |
| +// We don't want windows.h to define the macro max() which collides with |
| +// std::numeric_limits::max() |
| +#ifndef NOMINMAX |
| +#define NOMINMAX |
| +#endif |
| + |
| #include "common/windows/pdb_source_line_writer.h" |
| |
| #include <windows.h> |
| diff --git a/src/tools/windows/converter/ms_symbol_server_converter.cc b/src/tools/windows/converter/ms_symbol_server_converter.cc |
| old mode 100644 |
| new mode 100755 |
| index 71b77097..551502b2 |
| --- a/src/tools/windows/converter/ms_symbol_server_converter.cc |
| +++ b/src/tools/windows/converter/ms_symbol_server_converter.cc |
| @@ -422,7 +422,7 @@ BOOL CALLBACK MSSymbolServerConverter::SymCallback(HANDLE process, |
| |
| // static |
| BOOL CALLBACK MSSymbolServerConverter::SymFindFileInPathCallback( |
| - const char *filename, void *context) { |
| + PCSTR filename, PVOID context) { |
| // FALSE ends the search, indicating that the located symbol file is |
| // satisfactory. |
| return FALSE; |
| diff --git a/src/tools/windows/converter/ms_symbol_server_converter.gyp b/src/tools/windows/converter/ms_symbol_server_converter.gyp |
| index 57ec7906..d84be5c2 100644 |
| --- a/src/tools/windows/converter/ms_symbol_server_converter.gyp |
| +++ b/src/tools/windows/converter/ms_symbol_server_converter.gyp |
| @@ -42,5 +42,18 @@ |
| '../../../common/windows/common_windows.gyp:common_windows_lib', |
| ], |
| }, |
| + { |
| + 'target_name': 'symsrv_convert', |
| + 'type': 'executable', |
| + 'dependencies': [ |
| + 'ms_symbol_server_converter' |
| + ], |
| + 'sources' : [ |
| + 'symsrv_convert.cc', |
| + ], |
| + 'include_dirs': [ |
| + '<(DEPTH)', |
| + ], |
| + } |
| ], |
| } |
| diff --git a/src/tools/windows/converter/ms_symbol_server_converter.h b/src/tools/windows/converter/ms_symbol_server_converter.h |
| old mode 100644 |
| new mode 100755 |
| index d601b433..82aaea06 |
| --- a/src/tools/windows/converter/ms_symbol_server_converter.h |
| +++ b/src/tools/windows/converter/ms_symbol_server_converter.h |
| @@ -199,8 +199,8 @@ class MSSymbolServerConverter { |
| // SymFindFileInPath actually seems to accept NULL for a callback function |
| // and behave properly for our needs in that case, but the documentation |
| // doesn't mention it, so this little callback is provided. |
| - static BOOL CALLBACK SymFindFileInPathCallback(const char *filename, |
| - void *context); |
| + static BOOL CALLBACK SymFindFileInPathCallback(PCSTR filename, |
| + PVOID context); |
| |
| // The search path used by SymSrv, built based on the arguments to the |
| // constructor. |
| diff --git a/src/tools/windows/converter/symsrv_convert.cc b/src/tools/windows/converter/symsrv_convert.cc |
| new file mode 100644 |
| index 00000000..4c2a21df |
| --- /dev/null |
| +++ b/src/tools/windows/converter/symsrv_convert.cc |
| @@ -0,0 +1,61 @@ |
| +#include <cstdio> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "tools/windows/converter/ms_symbol_server_converter.h" |
| + |
| +using std::string; |
| +using std::vector; |
| +using google_breakpad::MissingSymbolInfo; |
| +using google_breakpad::MSSymbolServerConverter; |
| + |
| +int main(int argc, char *argv[]) |
| +{ |
| + if (argc < 5) { |
| + fprintf(stderr, "Usage: %s <symbol server> <symbol path> <debug file> <debug identifier>\n ", argv[0]); |
| + return 1; |
| + } |
| + |
| + MissingSymbolInfo missing_info; |
| + missing_info.debug_file = argv[3]; |
| + missing_info.debug_identifier = argv[4]; |
| + |
| + MSSymbolServerConverter converter(argv[2], vector<string>(1, argv[1])); |
| + string converted_file; |
| + |
| + MSSymbolServerConverter::LocateResult result = |
| + converter.LocateAndConvertSymbolFile(missing_info, |
| + false, |
| + false, |
| + &converted_file, |
| + NULL, |
| + NULL); |
| + printf("%s: ", argv[3]); |
| + int return_code; |
| + switch(result) { |
| + case MSSymbolServerConverter::LOCATE_SUCCESS: |
| + printf("converted: %s\n", converted_file.c_str()); |
| + return_code = 0; |
| + break; |
| + |
| + case MSSymbolServerConverter::LOCATE_RETRY: |
| + printf("try again later\n"); |
| + return_code = 1; |
| + break; |
| + |
| + case MSSymbolServerConverter::LOCATE_FAILURE: |
| + case MSSymbolServerConverter::LOCATE_NOT_FOUND: |
| + printf("failed to locate symbols\n"); |
| + return_code = 2; |
| + break; |
| + |
| + default: |
| + // ??? |
| + return_code = 3; |
| + break; |
| + } |
| + fflush(stdout); |
| + fflush(stderr); |
| + |
| + return return_code; |
| +} |
| -- |
| 2.15.0 |
| |