summaryrefslogtreecommitdiffstats
path: root/breakpad/linux
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-28 17:57:52 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-28 17:57:52 +0000
commita8f756f4116b9ffe2dea03c5af97e847704e51a4 (patch)
treefec2068cd9000975649820056978f0f6f3a09a24 /breakpad/linux
parent9941f620af64aafe096b2c6ba5fcebd03d50031d (diff)
downloadchromium_src-a8f756f4116b9ffe2dea03c5af97e847704e51a4.zip
chromium_src-a8f756f4116b9ffe2dea03c5af97e847704e51a4.tar.gz
chromium_src-a8f756f4116b9ffe2dea03c5af97e847704e51a4.tar.bz2
Linux Breakpad tweaking to get symbols working.
Do endian swapping for the identifier in dump_syms. Fill in the pdb_file_name (debug_file) field for modules. BUG=none TEST=none Review URL: http://codereview.chromium.org/113943 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17081 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'breakpad/linux')
-rw-r--r--breakpad/linux/file_id.cc16
-rw-r--r--breakpad/linux/minidump_writer.cc44
2 files changed, 45 insertions, 15 deletions
diff --git a/breakpad/linux/file_id.cc b/breakpad/linux/file_id.cc
index 5ba955b..ee0c0c2 100644
--- a/breakpad/linux/file_id.cc
+++ b/breakpad/linux/file_id.cc
@@ -34,6 +34,7 @@
#include "breakpad/linux/file_id.h"
+#include <arpa/inet.h>
#include <elf.h>
#include <fcntl.h>
#include <link.h>
@@ -82,12 +83,23 @@ bool FileID::ElfFileIdentifier(uint8_t identifier[kMDGUIDSize]) {
// static
void FileID::ConvertIdentifierToString(const uint8_t identifier[kMDGUIDSize],
char* buffer, int buffer_length) {
+ uint8_t identifier_swapped[kMDGUIDSize];
+
+ // Endian-ness swap to match dump processor expectation.
+ memcpy(identifier_swapped, identifier, kMDGUIDSize);
+ uint32_t* data1 = reinterpret_cast<uint32_t*>(identifier_swapped);
+ *data1 = htonl(*data1);
+ uint16_t* data2 = reinterpret_cast<uint16_t*>(identifier_swapped + 4);
+ *data2 = htons(*data2);
+ uint16_t* data3 = reinterpret_cast<uint16_t*>(identifier_swapped + 6);
+ *data3 = htons(*data3);
+
int buffer_idx = 0;
for (int idx = 0;
(buffer_idx < buffer_length) && (idx < kMDGUIDSize);
++idx) {
- int hi = (identifier[idx] >> 4) & 0x0F;
- int lo = (identifier[idx]) & 0x0F;
+ int hi = (identifier_swapped[idx] >> 4) & 0x0F;
+ int lo = (identifier_swapped[idx]) & 0x0F;
if (idx == 4 || idx == 6 || idx == 8 || idx == 10)
buffer[buffer_idx++] = '-';
diff --git a/breakpad/linux/minidump_writer.cc b/breakpad/linux/minidump_writer.cc
index 3887841..fbec6bd 100644
--- a/breakpad/linux/minidump_writer.cc
+++ b/breakpad/linux/minidump_writer.cc
@@ -512,21 +512,36 @@ class MinidumpWriter {
my_memset(&mod, 0, sizeof(mod));
mod.base_of_image = mapping.start_addr;
mod.size_of_image = mapping.size;
- UntypedMDRVA memory(&minidump_writer_);
- const size_t filename_len = my_strlen(mapping.name);
+ const size_t filepath_len = my_strlen(mapping.name);
+
+ // Figure out file name from path
+ const char* filename_ptr = mapping.name + filepath_len - 1;
+ while (filename_ptr >= mapping.name) {
+ if (*filename_ptr == '/')
+ break;
+ filename_ptr--;
+ }
+ filename_ptr++;
+ const size_t filename_len = mapping.name + filepath_len - filename_ptr;
- TypedMDRVA<MDCVInfoPDB70> cv(&minidump_writer_);
- if (!cv.Allocate())
+ uint8_t cv_buf[MDCVInfoPDB70_minsize + NAME_MAX];
+ uint8_t* cv_ptr = cv_buf;
+ UntypedMDRVA cv(&minidump_writer_);
+ if (!cv.Allocate(MDCVInfoPDB70_minsize + filename_len + 1))
return false;
- my_memset(cv.get(), 0, sizeof(MDCVInfoPDB70));
- cv.get()->cv_signature = MD_CVINFOPDB70_SIGNATURE;
+
+ const uint32_t cv_signature = MD_CVINFOPDB70_SIGNATURE;
+ memcpy(cv_ptr, &cv_signature, sizeof(cv_signature));
+ cv_ptr += sizeof(cv_signature);
{
// We XOR the first page of the file to get a signature for it.
uint8_t xor_buf[sizeof(MDGUID)];
size_t done = 0;
- uint8_t* const signature = (uint8_t*) &cv.get()->signature;
+ uint8_t* signature = cv_ptr;
+ cv_ptr += sizeof(xor_buf);
+ my_memset(signature, 0, sizeof(xor_buf));
while (done < 4096) {
dumper_.CopyFromProcess(xor_buf, crashing_tid_,
(void *) (mod.base_of_image + done),
@@ -535,16 +550,19 @@ class MinidumpWriter {
signature[i] ^= xor_buf[i];
done += sizeof(xor_buf);
}
+ cv_ptr += sizeof(uint32_t); // Skip age field
}
+ // Write pdb_file_name
+ memcpy(cv_ptr, filename_ptr, filename_len + 1);
+ cv.Copy(cv_buf, MDCVInfoPDB70_minsize + filename_len + 1);
+
mod.cv_record = cv.location();
- if (filename_len) {
- MDLocationDescriptor ld;
- if (!minidump_writer_.WriteString(mapping.name, filename_len, &ld))
- return false;
- mod.module_name_rva = ld.rva;
- }
+ MDLocationDescriptor ld;
+ if (!minidump_writer_.WriteString(mapping.name, filepath_len, &ld))
+ return false;
+ mod.module_name_rva = ld.rva;
list.CopyIndexAfterObject(j++, &mod, sizeof(mod));
}