1 //===-- MinidumpParser.cpp ---------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "MinidumpParser.h"
10 #include "NtStructures.h"
11 #include "RegisterContextMinidump_x86_32.h"
12 
13 #include "Plugins/Process/Utility/LinuxProcMaps.h"
14 #include "lldb/Utility/LLDBAssert.h"
15 #include "lldb/Utility/Log.h"
16 
17 // C includes
18 // C++ includes
19 #include <algorithm>
20 #include <map>
21 #include <vector>
22 #include <utility>
23 
24 using namespace lldb_private;
25 using namespace minidump;
26 
27 llvm::Expected<MinidumpParser>
28 MinidumpParser::Create(const lldb::DataBufferSP &data_sp) {
29   auto ExpectedFile = llvm::object::MinidumpFile::create(
30       llvm::MemoryBufferRef(toStringRef(data_sp->GetData()), "minidump"));
31   if (!ExpectedFile)
32     return ExpectedFile.takeError();
33 
34   return MinidumpParser(data_sp, std::move(*ExpectedFile));
35 }
36 
37 MinidumpParser::MinidumpParser(lldb::DataBufferSP data_sp,
38                                std::unique_ptr<llvm::object::MinidumpFile> file)
39     : m_data_sp(std::move(data_sp)), m_file(std::move(file)) {}
40 
41 llvm::ArrayRef<uint8_t> MinidumpParser::GetData() {
42   return llvm::ArrayRef<uint8_t>(m_data_sp->GetBytes(),
43                                  m_data_sp->GetByteSize());
44 }
45 
46 llvm::ArrayRef<uint8_t> MinidumpParser::GetStream(StreamType stream_type) {
47   return m_file->getRawStream(stream_type)
48       .getValueOr(llvm::ArrayRef<uint8_t>());
49 }
50 
51 UUID MinidumpParser::GetModuleUUID(const minidump::Module *module) {
52   auto cv_record =
53       GetData().slice(module->CvRecord.RVA, module->CvRecord.DataSize);
54 
55   // Read the CV record signature
56   const llvm::support::ulittle32_t *signature = nullptr;
57   Status error = consumeObject(cv_record, signature);
58   if (error.Fail())
59     return UUID();
60 
61   const CvSignature cv_signature =
62       static_cast<CvSignature>(static_cast<uint32_t>(*signature));
63 
64   if (cv_signature == CvSignature::Pdb70) {
65     const CvRecordPdb70 *pdb70_uuid = nullptr;
66     Status error = consumeObject(cv_record, pdb70_uuid);
67     if (error.Fail())
68       return UUID();
69 
70     CvRecordPdb70 swapped;
71     if (!GetArchitecture().GetTriple().isOSBinFormatELF()) {
72       // LLDB's UUID class treats the data as a sequence of bytes, but breakpad
73       // interprets it as a sequence of little-endian fields, which it converts
74       // to big-endian when converting to text. Swap the bytes to big endian so
75       // that the string representation comes out right.
76       swapped = *pdb70_uuid;
77       llvm::sys::swapByteOrder(swapped.Uuid.Data1);
78       llvm::sys::swapByteOrder(swapped.Uuid.Data2);
79       llvm::sys::swapByteOrder(swapped.Uuid.Data3);
80       llvm::sys::swapByteOrder(swapped.Age);
81       pdb70_uuid = &swapped;
82     }
83     if (pdb70_uuid->Age != 0)
84       return UUID::fromOptionalData(pdb70_uuid, sizeof(*pdb70_uuid));
85     return UUID::fromOptionalData(&pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid));
86   } else if (cv_signature == CvSignature::ElfBuildId)
87     return UUID::fromOptionalData(cv_record);
88 
89   return UUID();
90 }
91 
92 llvm::ArrayRef<minidump::Thread> MinidumpParser::GetThreads() {
93   auto ExpectedThreads = GetMinidumpFile().getThreadList();
94   if (ExpectedThreads)
95     return *ExpectedThreads;
96 
97   LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD),
98                  ExpectedThreads.takeError(),
99                  "Failed to read thread list: {0}");
100   return {};
101 }
102 
103 llvm::ArrayRef<uint8_t>
104 MinidumpParser::GetThreadContext(const LocationDescriptor &location) {
105   if (location.RVA + location.DataSize > GetData().size())
106     return {};
107   return GetData().slice(location.RVA, location.DataSize);
108 }
109 
110 llvm::ArrayRef<uint8_t>
111 MinidumpParser::GetThreadContext(const minidump::Thread &td) {
112   return GetThreadContext(td.Context);
113 }
114 
115 llvm::ArrayRef<uint8_t>
116 MinidumpParser::GetThreadContextWow64(const minidump::Thread &td) {
117   // On Windows, a 32-bit process can run on a 64-bit machine under WOW64. If
118   // the minidump was captured with a 64-bit debugger, then the CONTEXT we just
119   // grabbed from the mini_dump_thread is the one for the 64-bit "native"
120   // process rather than the 32-bit "guest" process we care about.  In this
121   // case, we can get the 32-bit CONTEXT from the TEB (Thread Environment
122   // Block) of the 64-bit process.
123   auto teb_mem = GetMemory(td.EnvironmentBlock, sizeof(TEB64));
124   if (teb_mem.empty())
125     return {};
126 
127   const TEB64 *wow64teb;
128   Status error = consumeObject(teb_mem, wow64teb);
129   if (error.Fail())
130     return {};
131 
132   // Slot 1 of the thread-local storage in the 64-bit TEB points to a structure
133   // that includes the 32-bit CONTEXT (after a ULONG). See:
134   // https://msdn.microsoft.com/en-us/library/ms681670.aspx
135   auto context =
136       GetMemory(wow64teb->tls_slots[1] + 4, sizeof(MinidumpContext_x86_32));
137   if (context.size() < sizeof(MinidumpContext_x86_32))
138     return {};
139 
140   return context;
141   // NOTE:  We don't currently use the TEB for anything else.  If we
142   // need it in the future, the 32-bit TEB is located according to the address
143   // stored in the first slot of the 64-bit TEB (wow64teb.Reserved1[0]).
144 }
145 
146 ArchSpec MinidumpParser::GetArchitecture() {
147   if (m_arch.IsValid())
148     return m_arch;
149 
150   // Set the architecture in m_arch
151   llvm::Expected<const SystemInfo &> system_info = m_file->getSystemInfo();
152 
153   if (!system_info) {
154     LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS),
155                    system_info.takeError(),
156                    "Failed to read SystemInfo stream: {0}");
157     return m_arch;
158   }
159 
160   // TODO what to do about big endiand flavors of arm ?
161   // TODO set the arm subarch stuff if the minidump has info about it
162 
163   llvm::Triple triple;
164   triple.setVendor(llvm::Triple::VendorType::UnknownVendor);
165 
166   switch (system_info->ProcessorArch) {
167   case ProcessorArchitecture::X86:
168     triple.setArch(llvm::Triple::ArchType::x86);
169     break;
170   case ProcessorArchitecture::AMD64:
171     triple.setArch(llvm::Triple::ArchType::x86_64);
172     break;
173   case ProcessorArchitecture::ARM:
174     triple.setArch(llvm::Triple::ArchType::arm);
175     break;
176   case ProcessorArchitecture::ARM64:
177     triple.setArch(llvm::Triple::ArchType::aarch64);
178     break;
179   default:
180     triple.setArch(llvm::Triple::ArchType::UnknownArch);
181     break;
182   }
183 
184   // TODO add all of the OSes that Minidump/breakpad distinguishes?
185   switch (system_info->PlatformId) {
186   case OSPlatform::Win32S:
187   case OSPlatform::Win32Windows:
188   case OSPlatform::Win32NT:
189   case OSPlatform::Win32CE:
190     triple.setOS(llvm::Triple::OSType::Win32);
191     triple.setVendor(llvm::Triple::VendorType::PC);
192     break;
193   case OSPlatform::Linux:
194     triple.setOS(llvm::Triple::OSType::Linux);
195     break;
196   case OSPlatform::MacOSX:
197     triple.setOS(llvm::Triple::OSType::MacOSX);
198     triple.setVendor(llvm::Triple::Apple);
199     break;
200   case OSPlatform::IOS:
201     triple.setOS(llvm::Triple::OSType::IOS);
202     triple.setVendor(llvm::Triple::Apple);
203     break;
204   case OSPlatform::Android:
205     triple.setOS(llvm::Triple::OSType::Linux);
206     triple.setEnvironment(llvm::Triple::EnvironmentType::Android);
207     break;
208   default: {
209     triple.setOS(llvm::Triple::OSType::UnknownOS);
210     auto ExpectedCSD = m_file->getString(system_info->CSDVersionRVA);
211     if (!ExpectedCSD) {
212       LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS),
213                      ExpectedCSD.takeError(),
214                      "Failed to CSD Version string: {0}");
215     } else {
216       if (ExpectedCSD->find("Linux") != std::string::npos)
217         triple.setOS(llvm::Triple::OSType::Linux);
218     }
219     break;
220   }
221   }
222   m_arch.SetTriple(triple);
223   return m_arch;
224 }
225 
226 const MinidumpMiscInfo *MinidumpParser::GetMiscInfo() {
227   llvm::ArrayRef<uint8_t> data = GetStream(StreamType::MiscInfo);
228 
229   if (data.size() == 0)
230     return nullptr;
231 
232   return MinidumpMiscInfo::Parse(data);
233 }
234 
235 llvm::Optional<LinuxProcStatus> MinidumpParser::GetLinuxProcStatus() {
236   llvm::ArrayRef<uint8_t> data = GetStream(StreamType::LinuxProcStatus);
237 
238   if (data.size() == 0)
239     return llvm::None;
240 
241   return LinuxProcStatus::Parse(data);
242 }
243 
244 llvm::Optional<lldb::pid_t> MinidumpParser::GetPid() {
245   const MinidumpMiscInfo *misc_info = GetMiscInfo();
246   if (misc_info != nullptr) {
247     return misc_info->GetPid();
248   }
249 
250   llvm::Optional<LinuxProcStatus> proc_status = GetLinuxProcStatus();
251   if (proc_status.hasValue()) {
252     return proc_status->GetPid();
253   }
254 
255   return llvm::None;
256 }
257 
258 llvm::ArrayRef<minidump::Module> MinidumpParser::GetModuleList() {
259   auto ExpectedModules = GetMinidumpFile().getModuleList();
260   if (ExpectedModules)
261     return *ExpectedModules;
262 
263   LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES),
264                  ExpectedModules.takeError(),
265                  "Failed to read module list: {0}");
266   return {};
267 }
268 
269 std::vector<const minidump::Module *> MinidumpParser::GetFilteredModuleList() {
270   Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
271   auto ExpectedModules = GetMinidumpFile().getModuleList();
272   if (!ExpectedModules) {
273     LLDB_LOG_ERROR(log, ExpectedModules.takeError(),
274                    "Failed to read module list: {0}");
275     return {};
276   }
277 
278   // map module_name -> filtered_modules index
279   typedef llvm::StringMap<size_t> MapType;
280   MapType module_name_to_filtered_index;
281 
282   std::vector<const minidump::Module *> filtered_modules;
283 
284   for (const auto &module : *ExpectedModules) {
285     auto ExpectedName = m_file->getString(module.ModuleNameRVA);
286     if (!ExpectedName) {
287       LLDB_LOG_ERROR(log, ExpectedName.takeError(),
288                      "Failed to get module name: {0}");
289       continue;
290     }
291 
292     MapType::iterator iter;
293     bool inserted;
294     // See if we have inserted this module aready into filtered_modules. If we
295     // haven't insert an entry into module_name_to_filtered_index with the
296     // index where we will insert it if it isn't in the vector already.
297     std::tie(iter, inserted) = module_name_to_filtered_index.try_emplace(
298         *ExpectedName, filtered_modules.size());
299 
300     if (inserted) {
301       // This module has not been seen yet, insert it into filtered_modules at
302       // the index that was inserted into module_name_to_filtered_index using
303       // "filtered_modules.size()" above.
304       filtered_modules.push_back(&module);
305     } else {
306       // This module has been seen. Modules are sometimes mentioned multiple
307       // times when they are mapped discontiguously, so find the module with
308       // the lowest "base_of_image" and use that as the filtered module.
309       auto dup_module = filtered_modules[iter->second];
310       if (module.BaseOfImage < dup_module->BaseOfImage)
311         filtered_modules[iter->second] = &module;
312     }
313   }
314   return filtered_modules;
315 }
316 
317 const MinidumpExceptionStream *MinidumpParser::GetExceptionStream() {
318   llvm::ArrayRef<uint8_t> data = GetStream(StreamType::Exception);
319 
320   if (data.size() == 0)
321     return nullptr;
322 
323   return MinidumpExceptionStream::Parse(data);
324 }
325 
326 llvm::Optional<minidump::Range>
327 MinidumpParser::FindMemoryRange(lldb::addr_t addr) {
328   llvm::ArrayRef<uint8_t> data64 = GetStream(StreamType::Memory64List);
329   Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
330 
331   auto ExpectedMemory = GetMinidumpFile().getMemoryList();
332   if (!ExpectedMemory) {
333     LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
334                    "Failed to read memory list: {0}");
335   } else {
336     for (const auto &memory_desc : *ExpectedMemory) {
337       const LocationDescriptor &loc_desc = memory_desc.Memory;
338       const lldb::addr_t range_start = memory_desc.StartOfMemoryRange;
339       const size_t range_size = loc_desc.DataSize;
340 
341       if (loc_desc.RVA + loc_desc.DataSize > GetData().size())
342         return llvm::None;
343 
344       if (range_start <= addr && addr < range_start + range_size) {
345         auto ExpectedSlice = GetMinidumpFile().getRawData(loc_desc);
346         if (!ExpectedSlice) {
347           LLDB_LOG_ERROR(log, ExpectedSlice.takeError(),
348                          "Failed to get memory slice: {0}");
349           return llvm::None;
350         }
351         return minidump::Range(range_start, *ExpectedSlice);
352       }
353     }
354   }
355 
356   // Some Minidumps have a Memory64ListStream that captures all the heap memory
357   // (full-memory Minidumps).  We can't exactly use the same loop as above,
358   // because the Minidump uses slightly different data structures to describe
359   // those
360 
361   if (!data64.empty()) {
362     llvm::ArrayRef<MinidumpMemoryDescriptor64> memory64_list;
363     uint64_t base_rva;
364     std::tie(memory64_list, base_rva) =
365         MinidumpMemoryDescriptor64::ParseMemory64List(data64);
366 
367     if (memory64_list.empty())
368       return llvm::None;
369 
370     for (const auto &memory_desc64 : memory64_list) {
371       const lldb::addr_t range_start = memory_desc64.start_of_memory_range;
372       const size_t range_size = memory_desc64.data_size;
373 
374       if (base_rva + range_size > GetData().size())
375         return llvm::None;
376 
377       if (range_start <= addr && addr < range_start + range_size) {
378         return minidump::Range(range_start,
379                                GetData().slice(base_rva, range_size));
380       }
381       base_rva += range_size;
382     }
383   }
384 
385   return llvm::None;
386 }
387 
388 llvm::ArrayRef<uint8_t> MinidumpParser::GetMemory(lldb::addr_t addr,
389                                                   size_t size) {
390   // I don't have a sense of how frequently this is called or how many memory
391   // ranges a Minidump typically has, so I'm not sure if searching for the
392   // appropriate range linearly each time is stupid.  Perhaps we should build
393   // an index for faster lookups.
394   llvm::Optional<minidump::Range> range = FindMemoryRange(addr);
395   if (!range)
396     return {};
397 
398   // There's at least some overlap between the beginning of the desired range
399   // (addr) and the current range.  Figure out where the overlap begins and how
400   // much overlap there is.
401 
402   const size_t offset = addr - range->start;
403 
404   if (addr < range->start || offset >= range->range_ref.size())
405     return {};
406 
407   const size_t overlap = std::min(size, range->range_ref.size() - offset);
408   return range->range_ref.slice(offset, overlap);
409 }
410 
411 static bool
412 CreateRegionsCacheFromLinuxMaps(MinidumpParser &parser,
413                                 std::vector<MemoryRegionInfo> &regions) {
414   auto data = parser.GetStream(StreamType::LinuxMaps);
415   if (data.empty())
416     return false;
417   ParseLinuxMapRegions(llvm::toStringRef(data),
418                        [&](const lldb_private::MemoryRegionInfo &region,
419                            const lldb_private::Status &status) -> bool {
420     if (status.Success())
421       regions.push_back(region);
422     return true;
423   });
424   return !regions.empty();
425 }
426 
427 static bool
428 CreateRegionsCacheFromMemoryInfoList(MinidumpParser &parser,
429                                      std::vector<MemoryRegionInfo> &regions) {
430   auto data = parser.GetStream(StreamType::MemoryInfoList);
431   if (data.empty())
432     return false;
433   auto mem_info_list = MinidumpMemoryInfo::ParseMemoryInfoList(data);
434   if (mem_info_list.empty())
435     return false;
436   constexpr auto yes = MemoryRegionInfo::eYes;
437   constexpr auto no = MemoryRegionInfo::eNo;
438   regions.reserve(mem_info_list.size());
439   for (const auto &entry : mem_info_list) {
440     MemoryRegionInfo region;
441     region.GetRange().SetRangeBase(entry->base_address);
442     region.GetRange().SetByteSize(entry->region_size);
443     region.SetReadable(entry->isReadable() ? yes : no);
444     region.SetWritable(entry->isWritable() ? yes : no);
445     region.SetExecutable(entry->isExecutable() ? yes : no);
446     region.SetMapped(entry->isMapped() ? yes : no);
447     regions.push_back(region);
448   }
449   return !regions.empty();
450 }
451 
452 static bool
453 CreateRegionsCacheFromMemoryList(MinidumpParser &parser,
454                                  std::vector<MemoryRegionInfo> &regions) {
455   Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
456   auto ExpectedMemory = parser.GetMinidumpFile().getMemoryList();
457   if (!ExpectedMemory) {
458     LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
459                    "Failed to read memory list: {0}");
460     return false;
461   }
462   regions.reserve(ExpectedMemory->size());
463   for (const MemoryDescriptor &memory_desc : *ExpectedMemory) {
464     if (memory_desc.Memory.DataSize == 0)
465       continue;
466     MemoryRegionInfo region;
467     region.GetRange().SetRangeBase(memory_desc.StartOfMemoryRange);
468     region.GetRange().SetByteSize(memory_desc.Memory.DataSize);
469     region.SetReadable(MemoryRegionInfo::eYes);
470     region.SetMapped(MemoryRegionInfo::eYes);
471     regions.push_back(region);
472   }
473   regions.shrink_to_fit();
474   return !regions.empty();
475 }
476 
477 static bool
478 CreateRegionsCacheFromMemory64List(MinidumpParser &parser,
479                                    std::vector<MemoryRegionInfo> &regions) {
480   llvm::ArrayRef<uint8_t> data =
481       parser.GetStream(StreamType::Memory64List);
482   if (data.empty())
483     return false;
484   llvm::ArrayRef<MinidumpMemoryDescriptor64> memory64_list;
485   uint64_t base_rva;
486   std::tie(memory64_list, base_rva) =
487       MinidumpMemoryDescriptor64::ParseMemory64List(data);
488 
489   if (memory64_list.empty())
490     return false;
491 
492   regions.reserve(memory64_list.size());
493   for (const auto &memory_desc : memory64_list) {
494     if (memory_desc.data_size == 0)
495       continue;
496     MemoryRegionInfo region;
497     region.GetRange().SetRangeBase(memory_desc.start_of_memory_range);
498     region.GetRange().SetByteSize(memory_desc.data_size);
499     region.SetReadable(MemoryRegionInfo::eYes);
500     region.SetMapped(MemoryRegionInfo::eYes);
501     regions.push_back(region);
502   }
503   regions.shrink_to_fit();
504   return !regions.empty();
505 }
506 
507 MemoryRegionInfo
508 MinidumpParser::FindMemoryRegion(lldb::addr_t load_addr) const {
509   auto begin = m_regions.begin();
510   auto end = m_regions.end();
511   auto pos = std::lower_bound(begin, end, load_addr);
512   if (pos != end && pos->GetRange().Contains(load_addr))
513     return *pos;
514 
515   MemoryRegionInfo region;
516   if (pos == begin)
517     region.GetRange().SetRangeBase(0);
518   else {
519     auto prev = pos - 1;
520     if (prev->GetRange().Contains(load_addr))
521       return *prev;
522     region.GetRange().SetRangeBase(prev->GetRange().GetRangeEnd());
523   }
524   if (pos == end)
525     region.GetRange().SetRangeEnd(UINT64_MAX);
526   else
527     region.GetRange().SetRangeEnd(pos->GetRange().GetRangeBase());
528   region.SetReadable(MemoryRegionInfo::eNo);
529   region.SetWritable(MemoryRegionInfo::eNo);
530   region.SetExecutable(MemoryRegionInfo::eNo);
531   region.SetMapped(MemoryRegionInfo::eNo);
532   return region;
533 }
534 
535 MemoryRegionInfo
536 MinidumpParser::GetMemoryRegionInfo(lldb::addr_t load_addr) {
537   if (!m_parsed_regions)
538     GetMemoryRegions();
539   return FindMemoryRegion(load_addr);
540 }
541 
542 const MemoryRegionInfos &MinidumpParser::GetMemoryRegions() {
543   if (!m_parsed_regions) {
544     m_parsed_regions = true;
545     // We haven't cached our memory regions yet we will create the region cache
546     // once. We create the region cache using the best source. We start with
547     // the linux maps since they are the most complete and have names for the
548     // regions. Next we try the MemoryInfoList since it has
549     // read/write/execute/map data, and then fall back to the MemoryList and
550     // Memory64List to just get a list of the memory that is mapped in this
551     // core file
552     if (!CreateRegionsCacheFromLinuxMaps(*this, m_regions))
553       if (!CreateRegionsCacheFromMemoryInfoList(*this, m_regions))
554         if (!CreateRegionsCacheFromMemoryList(*this, m_regions))
555           CreateRegionsCacheFromMemory64List(*this, m_regions);
556     llvm::sort(m_regions.begin(), m_regions.end());
557   }
558   return m_regions;
559 }
560 
561 #define ENUM_TO_CSTR(ST)                                                       \
562   case StreamType::ST:                                                         \
563     return #ST
564 
565 llvm::StringRef
566 MinidumpParser::GetStreamTypeAsString(StreamType stream_type) {
567   switch (stream_type) {
568     ENUM_TO_CSTR(Unused);
569     ENUM_TO_CSTR(ThreadList);
570     ENUM_TO_CSTR(ModuleList);
571     ENUM_TO_CSTR(MemoryList);
572     ENUM_TO_CSTR(Exception);
573     ENUM_TO_CSTR(SystemInfo);
574     ENUM_TO_CSTR(ThreadExList);
575     ENUM_TO_CSTR(Memory64List);
576     ENUM_TO_CSTR(CommentA);
577     ENUM_TO_CSTR(CommentW);
578     ENUM_TO_CSTR(HandleData);
579     ENUM_TO_CSTR(FunctionTable);
580     ENUM_TO_CSTR(UnloadedModuleList);
581     ENUM_TO_CSTR(MiscInfo);
582     ENUM_TO_CSTR(MemoryInfoList);
583     ENUM_TO_CSTR(ThreadInfoList);
584     ENUM_TO_CSTR(HandleOperationList);
585     ENUM_TO_CSTR(Token);
586     ENUM_TO_CSTR(JavascriptData);
587     ENUM_TO_CSTR(SystemMemoryInfo);
588     ENUM_TO_CSTR(ProcessVMCounters);
589     ENUM_TO_CSTR(LastReserved);
590     ENUM_TO_CSTR(BreakpadInfo);
591     ENUM_TO_CSTR(AssertionInfo);
592     ENUM_TO_CSTR(LinuxCPUInfo);
593     ENUM_TO_CSTR(LinuxProcStatus);
594     ENUM_TO_CSTR(LinuxLSBRelease);
595     ENUM_TO_CSTR(LinuxCMDLine);
596     ENUM_TO_CSTR(LinuxEnviron);
597     ENUM_TO_CSTR(LinuxAuxv);
598     ENUM_TO_CSTR(LinuxMaps);
599     ENUM_TO_CSTR(LinuxDSODebug);
600     ENUM_TO_CSTR(LinuxProcStat);
601     ENUM_TO_CSTR(LinuxProcUptime);
602     ENUM_TO_CSTR(LinuxProcFD);
603     ENUM_TO_CSTR(FacebookAppCustomData);
604     ENUM_TO_CSTR(FacebookBuildID);
605     ENUM_TO_CSTR(FacebookAppVersionName);
606     ENUM_TO_CSTR(FacebookJavaStack);
607     ENUM_TO_CSTR(FacebookDalvikInfo);
608     ENUM_TO_CSTR(FacebookUnwindSymbols);
609     ENUM_TO_CSTR(FacebookDumpErrorLog);
610     ENUM_TO_CSTR(FacebookAppStateLog);
611     ENUM_TO_CSTR(FacebookAbortReason);
612     ENUM_TO_CSTR(FacebookThreadName);
613     ENUM_TO_CSTR(FacebookLogcat);
614   }
615   return "unknown stream type";
616 }
617