Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: breakpad/linux/minidump_writer.cc

Issue 146001: Fill in sys_info->csd_version_rva on Linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009, Google Inc. 1 // Copyright (c) 2009, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // new form to allocate objects and we don't delete them. 44 // new form to allocate objects and we don't delete them.
45 45
46 #include "breakpad/linux/minidump_writer.h" 46 #include "breakpad/linux/minidump_writer.h"
47 #include "client/minidump_file_writer-inl.h" 47 #include "client/minidump_file_writer-inl.h"
48 48
49 #include <unistd.h> 49 #include <unistd.h>
50 #include <fcntl.h> 50 #include <fcntl.h>
51 #include <errno.h> 51 #include <errno.h>
52 #include <sys/ucontext.h> 52 #include <sys/ucontext.h>
53 #include <sys/user.h> 53 #include <sys/user.h>
54 #include <sys/utsname.h>
54 55
55 #include "client/minidump_file_writer.h" 56 #include "client/minidump_file_writer.h"
56 #include "google_breakpad/common/minidump_format.h" 57 #include "google_breakpad/common/minidump_format.h"
57 #include "google_breakpad/common/minidump_cpu_amd64.h" 58 #include "google_breakpad/common/minidump_cpu_amd64.h"
58 #include "google_breakpad/common/minidump_cpu_x86.h" 59 #include "google_breakpad/common/minidump_cpu_x86.h"
59 60
60 #include "breakpad/linux/exception_handler.h" 61 #include "breakpad/linux/exception_handler.h"
61 #include "breakpad/linux/linux_dumper.h" 62 #include "breakpad/linux/linux_dumper.h"
62 #include "breakpad/linux/linux_libc_support.h" 63 #include "breakpad/linux/linux_libc_support.h"
63 #include "breakpad/linux/linux_syscall_support.h" 64 #include "breakpad/linux/linux_syscall_support.h"
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 bool WriteSystemInfoStream(MDRawDirectory* dirent) { 593 bool WriteSystemInfoStream(MDRawDirectory* dirent) {
593 TypedMDRVA<MDRawSystemInfo> si(&minidump_writer_); 594 TypedMDRVA<MDRawSystemInfo> si(&minidump_writer_);
594 if (!si.Allocate()) 595 if (!si.Allocate())
595 return false; 596 return false;
596 my_memset(si.get(), 0, sizeof(MDRawSystemInfo)); 597 my_memset(si.get(), 0, sizeof(MDRawSystemInfo));
597 598
598 dirent->stream_type = MD_SYSTEM_INFO_STREAM; 599 dirent->stream_type = MD_SYSTEM_INFO_STREAM;
599 dirent->location = si.location(); 600 dirent->location = si.location();
600 601
601 WriteCPUInformation(si.get()); 602 WriteCPUInformation(si.get());
603 WriteOSInformation(si.get());
602 604
603 return true; 605 return true;
604 } 606 }
605 607
606 private: 608 private:
607 #if defined(__i386) 609 #if defined(__i386)
608 uintptr_t GetStackPointer() { 610 uintptr_t GetStackPointer() {
609 return ucontext_->uc_mcontext.gregs[REG_ESP]; 611 return ucontext_->uc_mcontext.gregs[REG_ESP];
610 } 612 }
611 #elif defined(__x86_64) 613 #elif defined(__x86_64)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 return false; 765 return false;
764 766
765 UntypedMDRVA memory(&minidump_writer_); 767 UntypedMDRVA memory(&minidump_writer_);
766 if (!memory.Allocate(done)) 768 if (!memory.Allocate(done))
767 return false; 769 return false;
768 memory.Copy(data, done); 770 memory.Copy(data, done);
769 *result = memory.location(); 771 *result = memory.location();
770 return true; 772 return true;
771 } 773 }
772 774
775 bool WriteOSInformation(MDRawSystemInfo* sys_info) {
776 sys_info->platform_id = MD_OS_LINUX;
777
778 struct utsname uts;
779 if (uname(&uts))
780 return false;
781
782 static const size_t buf_len = 512;
783 char buf[buf_len] = {0};
784 size_t space_left = buf_len - 1;
785 const char* info_table[] = {
786 uts.sysname,
787 uts.release,
788 uts.version,
789 uts.machine,
790 NULL
791 };
792 bool first_item = true;
793 for (const char** cur_info = info_table; *cur_info; cur_info++) {
794 static const char* separator = " ";
795 size_t separator_len = strlen(separator);
796 size_t info_len = strlen(*cur_info);
797 if (info_len == 0)
798 continue;
799
800 if (space_left < info_len + (first_item ? 0 : separator_len))
801 break;
802
803 if (!first_item) {
804 strcat(buf, separator);
805 space_left -= separator_len;
806 }
807
808 first_item = false;
809 strcat(buf, *cur_info);
810 space_left -= info_len;
811 }
812
813 MDLocationDescriptor location;
814 if (!minidump_writer_.WriteString(buf, 0, &location))
815 return false;
816 sys_info->csd_version_rva = location.rva;
817
818 return true;
819 }
820
773 bool WriteProcFile(MDLocationDescriptor* result, pid_t pid, 821 bool WriteProcFile(MDLocationDescriptor* result, pid_t pid,
774 const char* filename) { 822 const char* filename) {
775 char buf[80]; 823 char buf[80];
776 memcpy(buf, "/proc/", 6); 824 memcpy(buf, "/proc/", 6);
777 const unsigned pid_len = my_int_len(pid); 825 const unsigned pid_len = my_int_len(pid);
778 my_itos(buf + 6, pid, pid_len); 826 my_itos(buf + 6, pid, pid_len);
779 buf[6 + pid_len] = '/'; 827 buf[6 + pid_len] = '/';
780 memcpy(buf + 6 + pid_len + 1, filename, my_strlen(filename) + 1); 828 memcpy(buf + 6 + pid_len + 1, filename, my_strlen(filename) + 1);
781 return WriteFile(result, buf); 829 return WriteFile(result, buf);
782 } 830 }
(...skipping 14 matching lines...) Expand all
797 return false; 845 return false;
798 const ExceptionHandler::CrashContext* context = 846 const ExceptionHandler::CrashContext* context =
799 reinterpret_cast<const ExceptionHandler::CrashContext*>(blob); 847 reinterpret_cast<const ExceptionHandler::CrashContext*>(blob);
800 MinidumpWriter writer(filename, crashing_process, context); 848 MinidumpWriter writer(filename, crashing_process, context);
801 if (!writer.Init()) 849 if (!writer.Init())
802 return false; 850 return false;
803 return writer.Dump(); 851 return writer.Dump();
804 } 852 }
805 853
806 } // namespace google_breakpad 854 } // namespace google_breakpad
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698