diff options
Diffstat (limited to 'src/common/windows/pdb_source_line_writer.cc')
-rw-r--r-- | src/common/windows/pdb_source_line_writer.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/common/windows/pdb_source_line_writer.cc b/src/common/windows/pdb_source_line_writer.cc index 58588089..c6c1d5c4 100644 --- a/src/common/windows/pdb_source_line_writer.cc +++ b/src/common/windows/pdb_source_line_writer.cc @@ -32,6 +32,8 @@ #include <dia2.h> #include <stdio.h> +#include "common/windows/string_utils-inl.h" + #include "common/windows/pdb_source_line_writer.h" #include "common/windows/guid_string.h" @@ -161,7 +163,7 @@ bool PDBSourceLineWriter::PrintFunction(IDiaSymbol *function) { stack_param_size = GetFunctionStackParamSize(function); } - fprintf(output_, "FUNC %x %llx %x %ws\n", + fprintf(output_, "FUNC %x %" WIN_STRING_FORMAT_LL "x %x %ws\n", rva, length, stack_param_size, name); CComPtr<IDiaEnumLineNumbers> lines; @@ -461,6 +463,11 @@ bool PDBSourceLineWriter::GetSymbolFunctionName(IDiaSymbol *function, // If a name comes from get_name because no undecorated form existed, // it's already formatted properly to be used as output. Don't do any // additional processing. + // + // MSVC7's DIA seems to not undecorate names in as many cases as MSVC8's. + // This will result in calling get_name for some C++ symbols, so + // all of the parameter and return type information may not be included in + // the name string. } else { // C++ uses a bogus "void" argument for functions and methods that don't // take any parameters. Take it out of the undecorated name because it's @@ -472,7 +479,8 @@ bool PDBSourceLineWriter::GetSymbolFunctionName(IDiaSymbol *function, if (length >= replace_length) { wchar_t *name_end = *name + length - replace_length; if (wcscmp(name_end, replace_string) == 0) { - wcscpy_s(name_end, replace_length, replacement_string); + WindowsStringUtils::safe_wcscpy(name_end, replace_length, + replacement_string); length = wcslen(*name); } } @@ -501,13 +509,14 @@ bool PDBSourceLineWriter::GetSymbolFunctionName(IDiaSymbol *function, // Undecorate the name by moving it one character to the left in its // buffer, and terminating it where the last '@' had been. - wcsncpy_s(*name, length, *name + 1, last_at - *name - 1); - } else if (*name[0] == '_') { + WindowsStringUtils::safe_wcsncpy(*name, length, + *name + 1, last_at - *name - 1); + } else if (*name[0] == '_') { // This symbol's name is encoded according to the cdecl rules. The // name doesn't end in a '@' character followed by a decimal positive // integer, so it's not a stdcall name. Strip off the leading // underscore. - wcsncpy_s(*name, length, *name + 1, length - 1); + WindowsStringUtils::safe_wcsncpy(*name, length, *name + 1, length); } } } |