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

Side by Side Diff: src/google_breakpad/processor/minidump.h

Issue 1251593007: Add support for Linux memory mapping stream and remove ELF header usage (Closed) Base URL: http://google-breakpad.googlecode.com/svn/trunk/
Patch Set: Created 5 years, 5 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
OLDNEW
1 // Copyright (c) 2010 Google Inc. 1 // Copyright (c) 2010 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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 845
846 bool Read(uint32_t expected_size); 846 bool Read(uint32_t expected_size);
847 847
848 // Access to memory info using addresses as the key. 848 // Access to memory info using addresses as the key.
849 RangeMap<uint64_t, unsigned int> *range_map_; 849 RangeMap<uint64_t, unsigned int> *range_map_;
850 850
851 MinidumpMemoryInfos* infos_; 851 MinidumpMemoryInfos* infos_;
852 uint32_t info_count_; 852 uint32_t info_count_;
853 }; 853 };
854 854
855 // MinidumpLinuxMaps wraps information about a single mapped memory region
856 // from /proc/self/maps.
857 class MinidumpLinuxMaps : public MinidumpObject {
858 public:
859 virtual ~MinidumpLinuxMaps();
860
861 // The memory address of the base of the mapped region.
862 uint64_t GetBase() const { return valid_ ? base_address_ : 0; }
863 // The size of the mapped region.
864 uint64_t GetSize() const { return valid_ ? region_size_ : 0; }
865
866 // The permissions of the mapped region.
867 bool IsReadable() const { return valid_ ? is_readable_ : false; }
868 bool IsWriteable() const { return valid_ ? is_writeable_ : false; }
869 bool IsExecutable() const { return valid_ ? is_executable_ : false; }
870 bool IsShared() const { return valid_ ? is_shared_ : false; }
871
872 // The offset of the mapped region.
873 uint64_t GetOffset() const { return valid_ ? offset_ : 0; }
874
875 // The major device number.
876 uint8_t GetMajorDevice() const { return valid_ ? major_device_ : 0; }
877 // The minor device number.
878 uint8_t GetMinorDevice() const { return valid_ ? minor_device_ : 0; }
879
880 // The inode of the mapped region.
881 uint32_t GetInode() const { return valid_ ? inode_ : 0; }
882
883 // The pathname of the mapped region.
884 const string GetPathname() const { return valid_ ? pathname_ : NULL; }
885
886 // Print the contents of this mapping.
887 void Print();
888
889 private:
890 // These objects are managed by MinidumpLinuxMapsList.
891 friend class MinidumpLinuxMapsList;
892
893 explicit MinidumpLinuxMaps(Minidump *minidump);
ivanpe 2015/07/23 01:17:12 Please, document who should own the memory for the
liuandrew 2015/07/24 23:25:35 Done.
894
895 // Read data about a single mapping from /proc/self/maps and load the data
896 // into this object. The input vector is in the same format as a line from
897 // /proc/self/maps.
898 bool Read(vector<char> *data);
ivanpe 2015/07/23 01:17:12 Is this an input parameter? Passing as const vect
liuandrew 2015/07/24 23:25:35 Removed method.
899
900 // Instance variables.
ivanpe 2015/07/23 01:17:12 This comment is not very useful. Please, comment
liuandrew 2015/07/24 23:25:35 Removed these instance variables.
901 uint64_t base_address_;
902 uint64_t region_size_;
903 bool is_readable_;
904 bool is_writeable_;
905 bool is_executable_;
906 bool is_shared_;
907 uint64_t offset_;
908 uint8_t major_device_;
909 uint8_t minor_device_;
910 uint32_t inode_;
911 string pathname_;
912 vector<char> *raw_linux_maps_;
913 };
ivanpe 2015/07/23 01:17:12 DISALLOW_COPY_AND_ASSIGN(MinidumpLinuxMaps);
liuandrew 2015/07/24 23:25:35 Why do I need this? What does it do? The other cla
ivanpe 2015/07/27 18:12:42 If you do not want to support copy/move operations
liuandrew 2015/07/27 23:09:26 Done.
914
915 // MinidumpLinuxMapsList corresponds to the Linux-exclusive MD_LINUX_MAPS
916 // stream, which contains the contents of /prod/self/maps, which contains
917 // the mapped memory regions and their access permissions.
918 class MinidumpLinuxMapsList : public MinidumpStream {
919 public:
920 virtual ~MinidumpLinuxMapsList();
921
922 // Get mapping at the given memory address.
923 const MinidumpLinuxMaps *GetLinuxMapsForAddress(uint64_t address) const;
ivanpe 2015/07/23 01:17:12 Please, document who owns the memory for the retur
liuandrew 2015/07/24 23:25:36 Done.
924 // Get mapping at the given index.
925 const MinidumpLinuxMaps *GetLinuxMapsAtIndex(unsigned int index) const;
ivanpe 2015/07/23 01:17:12 Please, document who owns the memory for the retur
liuandrew 2015/07/24 23:25:35 Done.
926
927 // Print the contents of /proc/self/maps to stdout.
928 void Print();
929
930 private:
931 friend class Minidump;
932
933 typedef vector<MinidumpLinuxMaps *> MinidumpLinuxMappings;
934
935 static const uint32_t kStreamType = MD_LINUX_MAPS;
936
937 explicit MinidumpLinuxMapsList(Minidump *minidump);
ivanpe 2015/07/23 01:17:12 Again, please, describe who owns the passed in poi
liuandrew 2015/07/24 23:25:35 Done.
938
939 // Read and load the contents of the process mapping data.
940 // The stream should have data in the form of /proc/self/maps.
941 bool Read(uint32_t expected_size);
ivanpe 2015/07/23 01:17:12 Please, document return value? What happens when
liuandrew 2015/07/24 23:25:36 Done.
942
943 // Instance variables.
ivanpe 2015/07/23 01:17:12 Please, document the individual members instead.
liuandrew 2015/07/24 23:25:35 Done.
944 MinidumpLinuxMappings *maps_;
945 uint32_t maps_count_;
946 vector<char> raw_linux_maps_list_;
947 };
ivanpe 2015/07/23 01:17:12 DISALLOW_COPY_AND_ASSIGN(MinidumpLinuxMapsList);
liuandrew 2015/07/24 23:25:35 See response for similar comment.
ivanpe 2015/07/27 18:12:41 Please, take a look at my other response. Thanks.
liuandrew 2015/07/27 23:09:26 Done.
855 948
856 // Minidump is the user's interface to a minidump file. It wraps MDRawHeader 949 // Minidump is the user's interface to a minidump file. It wraps MDRawHeader
857 // and provides access to the minidump's top-level stream directory. 950 // and provides access to the minidump's top-level stream directory.
858 class Minidump { 951 class Minidump {
859 public: 952 public:
860 // path is the pathname of a file containing the minidump. 953 // path is the pathname of a file containing the minidump.
861 explicit Minidump(const string& path); 954 explicit Minidump(const string& path);
862 // input is an istream wrapping minidump data. Minidump holds a 955 // input is an istream wrapping minidump data. Minidump holds a
863 // weak pointer to input, and the caller must ensure that the stream 956 // weak pointer to input, and the caller must ensure that the stream
864 // is valid as long as the Minidump object is. 957 // is valid as long as the Minidump object is.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 virtual MinidumpThreadList* GetThreadList(); 998 virtual MinidumpThreadList* GetThreadList();
906 virtual MinidumpModuleList* GetModuleList(); 999 virtual MinidumpModuleList* GetModuleList();
907 virtual MinidumpMemoryList* GetMemoryList(); 1000 virtual MinidumpMemoryList* GetMemoryList();
908 virtual MinidumpException* GetException(); 1001 virtual MinidumpException* GetException();
909 virtual MinidumpAssertion* GetAssertion(); 1002 virtual MinidumpAssertion* GetAssertion();
910 virtual MinidumpSystemInfo* GetSystemInfo(); 1003 virtual MinidumpSystemInfo* GetSystemInfo();
911 virtual MinidumpMiscInfo* GetMiscInfo(); 1004 virtual MinidumpMiscInfo* GetMiscInfo();
912 virtual MinidumpBreakpadInfo* GetBreakpadInfo(); 1005 virtual MinidumpBreakpadInfo* GetBreakpadInfo();
913 virtual MinidumpMemoryInfoList* GetMemoryInfoList(); 1006 virtual MinidumpMemoryInfoList* GetMemoryInfoList();
914 1007
1008 // The next method also calls GetStream, but is exclusive for Linux dumps.
1009 virtual MinidumpLinuxMapsList *GetLinuxMapsList();
1010
915 // The next set of methods are provided for users who wish to access 1011 // The next set of methods are provided for users who wish to access
916 // data in minidump files directly, while leveraging the rest of 1012 // data in minidump files directly, while leveraging the rest of
917 // this class and related classes to handle the basic minidump 1013 // this class and related classes to handle the basic minidump
918 // structure and known stream types. 1014 // structure and known stream types.
919 1015
920 unsigned int GetDirectoryEntryCount() const { 1016 unsigned int GetDirectoryEntryCount() const {
921 return valid_ ? header_.stream_count : 0; 1017 return valid_ ? header_.stream_count : 0;
922 } 1018 }
923 const MDRawDirectory* GetDirectoryEntryAtIndex(unsigned int index) const; 1019 const MDRawDirectory* GetDirectoryEntryAtIndex(unsigned int index) const;
924 1020
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 // construction or after a failed Read(); true following a successful 1117 // construction or after a failed Read(); true following a successful
1022 // Read(). 1118 // Read().
1023 bool valid_; 1119 bool valid_;
1024 }; 1120 };
1025 1121
1026 1122
1027 } // namespace google_breakpad 1123 } // namespace google_breakpad
1028 1124
1029 1125
1030 #endif // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_H__ 1126 #endif // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_H__
OLDNEW
« no previous file with comments | « no previous file | src/processor/exploitability_linux.cc » ('j') | src/processor/exploitability_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698