mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2025-12-24 16:24:52 +01:00
Make dump_syms output an INFO CODE_ID line that includes the code file and code identifier. (Currently disabled to give Breakpad users time to update their processor code.)
R=mark at http://breakpad.appspot.com/180001/show git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@710 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
d192a71e24
commit
d35f113d02
7 changed files with 211 additions and 16 deletions
|
|
@ -28,6 +28,7 @@
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
|
||||
#include "common/windows/string_utils-inl.h"
|
||||
|
||||
|
|
@ -55,6 +56,7 @@ bool WindowsStringUtils::safe_mbstowcs(const string &mbs, wstring *wcs) {
|
|||
if ((err = mbstowcs_s(&wcs_length, NULL, 0, mbs.c_str(), _TRUNCATE)) != 0) {
|
||||
return false;
|
||||
}
|
||||
assert(wcs_length > 0);
|
||||
#else // _MSC_VER >= 1400
|
||||
if ((wcs_length = mbstowcs(NULL, mbs.c_str(), mbs.length())) < 0) {
|
||||
return false;
|
||||
|
|
@ -64,28 +66,67 @@ bool WindowsStringUtils::safe_mbstowcs(const string &mbs, wstring *wcs) {
|
|||
++wcs_length;
|
||||
#endif // _MSC_VER >= 1400
|
||||
|
||||
// TODO(mmentovai): move scoped_ptr into common and use it for wcs_c.
|
||||
wchar_t *wcs_c = new wchar_t[wcs_length];
|
||||
std::vector<wchar_t> wcs_v(wcs_length);
|
||||
|
||||
// Now, convert.
|
||||
#if _MSC_VER >= 1400 // MSVC 2005/8
|
||||
if ((err = mbstowcs_s(NULL, wcs_c, wcs_length, mbs.c_str(),
|
||||
if ((err = mbstowcs_s(NULL, &wcs_v[0], wcs_length, mbs.c_str(),
|
||||
_TRUNCATE)) != 0) {
|
||||
delete[] wcs_c;
|
||||
return false;
|
||||
}
|
||||
#else // _MSC_VER >= 1400
|
||||
if (mbstowcs(wcs_c, mbs.c_str(), mbs.length()) < 0) {
|
||||
delete[] wcs_c;
|
||||
if (mbstowcs(&wcs_v[0], mbs.c_str(), mbs.length()) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure presence of 0-terminator.
|
||||
wcs_c[wcs_length - 1] = '\0';
|
||||
wcs_v[wcs_length - 1] = '\0';
|
||||
#endif // _MSC_VER >= 1400
|
||||
|
||||
*wcs = wcs_c;
|
||||
delete[] wcs_c;
|
||||
*wcs = &wcs_v[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
bool WindowsStringUtils::safe_wcstombs(const wstring &wcs, string *mbs) {
|
||||
assert(mbs);
|
||||
|
||||
// First, determine the length of the destination buffer.
|
||||
size_t mbs_length;
|
||||
|
||||
#if _MSC_VER >= 1400 // MSVC 2005/8
|
||||
errno_t err;
|
||||
if ((err = wcstombs_s(&mbs_length, NULL, 0, wcs.c_str(), _TRUNCATE)) != 0) {
|
||||
return false;
|
||||
}
|
||||
assert(mbs_length > 0);
|
||||
#else // _MSC_VER >= 1400
|
||||
if ((mbs_length = wcstombs(NULL, wcs.c_str(), wcs.length())) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Leave space for the 0-terminator.
|
||||
++mbs_length;
|
||||
#endif // _MSC_VER >= 1400
|
||||
|
||||
std::vector<char> mbs_v(mbs_length);
|
||||
|
||||
// Now, convert.
|
||||
#if _MSC_VER >= 1400 // MSVC 2005/8
|
||||
if ((err = wcstombs_s(NULL, &mbs_v[0], mbs_length, wcs.c_str(),
|
||||
_TRUNCATE)) != 0) {
|
||||
return false;
|
||||
}
|
||||
#else // _MSC_VER >= 1400
|
||||
if (wcstombs(&mbs_v[0], wcs.c_str(), wcs.length()) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure presence of 0-terminator.
|
||||
mbs_v[mbs_length - 1] = '\0';
|
||||
#endif // _MSC_VER >= 1400
|
||||
|
||||
*mbs = &mbs_v[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue