|
41 | 41 |
|
42 | 42 | #include <algorithm> |
43 | 43 | #include <cinttypes> |
44 | | -#include <climits> |
45 | 44 | #include <cstddef> |
46 | 45 | #include <cstdint> |
47 | | -#include <functional> |
48 | | -#include <iostream> |
49 | | -#include <set> |
50 | 46 | #include <utility> |
51 | | -#include <vector> |
52 | 47 |
|
53 | 48 | using namespace lldb; |
54 | 49 | using namespace lldb_private; |
@@ -879,8 +874,8 @@ Status MinidumpFileBuilder::AddMemoryList() { |
879 | 874 | // We apply a generous padding here so that the Directory, MemoryList and |
880 | 875 | // Memory64List sections all begin in 32b addressable space. |
881 | 876 | // Then anything overflow extends into 64b addressable space. |
882 | | - // All core memeroy ranges will either container nothing on stacks only |
883 | | - // or all the memory ranges including stacks |
| 877 | + // all_core_memory_vec will either contain all stack regions at this point, |
| 878 | + // or be empty if it's a stack only minidump. |
884 | 879 | if (!all_core_memory_vec.empty()) |
885 | 880 | total_size += 256 + (all_core_memory_vec.size() * |
886 | 881 | sizeof(llvm::minidump::MemoryDescriptor_64)); |
@@ -924,9 +919,9 @@ Status MinidumpFileBuilder::DumpHeader() const { |
924 | 919 | header.StreamDirectoryRVA = |
925 | 920 | static_cast<llvm::support::ulittle32_t>(HEADER_SIZE); |
926 | 921 | header.Checksum = static_cast<llvm::support::ulittle32_t>( |
927 | | - 0u), // not used in most of the writers |
928 | | - header.TimeDateStamp = |
929 | | - static_cast<llvm::support::ulittle32_t>(std::time(nullptr)); |
| 922 | + 0u); // not used in most of the writers |
| 923 | + header.TimeDateStamp = |
| 924 | + static_cast<llvm::support::ulittle32_t>(std::time(nullptr)); |
930 | 925 | header.Flags = |
931 | 926 | static_cast<llvm::support::ulittle64_t>(0u); // minidump normal flag |
932 | 927 |
|
@@ -987,10 +982,10 @@ Status MinidumpFileBuilder::ReadWriteMemoryInChunks( |
987 | 982 | current_addr, bytes_read, error.AsCString()); |
988 | 983 |
|
989 | 984 | // If we failed in a memory read, we would normally want to skip |
990 | | - // this entire region, if we had already written to the minidump |
| 985 | + // this entire region. If we had already written to the minidump |
991 | 986 | // file, we can't easily rewind that state. |
992 | 987 | // |
993 | | - // So if we do encounter an error while reading, we just return |
| 988 | + // So if we do encounter an error while reading, we return |
994 | 989 | // immediately, any prior bytes read will still be included but |
995 | 990 | // any bytes partially read before the error are ignored. |
996 | 991 | return lldb_private::IterationAction::Stop; |
@@ -1069,7 +1064,7 @@ MinidumpFileBuilder::AddMemoryList_32(std::vector<CoreFileMemoryRange> &ranges, |
1069 | 1064 | return error; |
1070 | 1065 |
|
1071 | 1066 | // If we completely failed to read this range |
1072 | | - // we can just omit any of the book keeping. |
| 1067 | + // we can drop the memory range |
1073 | 1068 | if (bytes_read == 0) |
1074 | 1069 | continue; |
1075 | 1070 |
|
@@ -1209,12 +1204,7 @@ MinidumpFileBuilder::AddMemoryList_64(std::vector<CoreFileMemoryRange> &ranges, |
1209 | 1204 | } |
1210 | 1205 |
|
1211 | 1206 | Status MinidumpFileBuilder::AddData(const void *data, uint64_t size) { |
1212 | | - // This should also get chunked, because worst case we copy over a big |
1213 | | - // object / memory range, say 5gb. In that case, we'd have to allocate 10gb |
1214 | | - // 5 gb for the buffer we're copying from, and then 5gb for the buffer we're |
1215 | | - // copying to. Which will be short lived and immedaitely go to disk, the goal |
1216 | | - // here is to limit the number of bytes we need to host in memory at any given |
1217 | | - // time. |
| 1207 | + // Append the data to the buffer, if the buffer spills over, flush it to disk |
1218 | 1208 | m_data.AppendData(data, size); |
1219 | 1209 | if (m_data.GetByteSize() > MAX_WRITE_CHUNK_SIZE) |
1220 | 1210 | return FlushBufferToDisk(); |
|
0 commit comments