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   Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
431   auto ExpectedInfo = parser.GetMinidumpFile().getMemoryInfoList();
432   if (!ExpectedInfo) {
433     LLDB_LOG_ERROR(log, ExpectedInfo.takeError(),
434                    "Failed to read memory info list: {0}");
435     return false;
436   }
437   constexpr auto yes = MemoryRegionInfo::eYes;
438   constexpr auto no = MemoryRegionInfo::eNo;
439   for (const MemoryInfo &entry : *ExpectedInfo) {
440     MemoryRegionInfo region;
441     region.GetRange().SetRangeBase(entry.BaseAddress);
442     region.GetRange().SetByteSize(entry.RegionSize);
443 
444     MemoryProtection prot = entry.Protect;
445     region.SetReadable(bool(prot & MemoryProtection::NoAccess) ? no : yes);
446     region.SetWritable(
447         bool(prot & (MemoryProtection::ReadWrite | MemoryProtection::WriteCopy |
448                      MemoryProtection::ExecuteReadWrite |
449                      MemoryProtection::ExeciteWriteCopy))
450             ? yes
451             : no);
452     region.SetExecutable(
453         bool(prot & (MemoryProtection::Execute | MemoryProtection::ExecuteRead |
454                      MemoryProtection::ExecuteReadWrite |
455                      MemoryProtection::ExeciteWriteCopy))
456             ? yes
457             : no);
458     region.SetMapped(entry.State != MemoryState::Free ? yes : no);
459     regions.push_back(region);
460   }
461   return !regions.empty();
462 }
463 
464 static bool
465 CreateRegionsCacheFromMemoryList(MinidumpParser &parser,
466                                  std::vector<MemoryRegionInfo> &regions) {
467   Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
468   auto ExpectedMemory = parser.GetMinidumpFile().getMemoryList();
469   if (!ExpectedMemory) {
470     LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
471                    "Failed to read memory list: {0}");
472     return false;
473   }
474   regions.reserve(ExpectedMemory->size());
475   for (const MemoryDescriptor &memory_desc : *ExpectedMemory) {
476     if (memory_desc.Memory.DataSize == 0)
477       continue;
478     MemoryRegionInfo region;
479     region.GetRange().SetRangeBase(memory_desc.StartOfMemoryRange);
480     region.GetRange().SetByteSize(memory_desc.Memory.DataSize);
481     region.SetReadable(MemoryRegionInfo::eYes);
482     region.SetMapped(MemoryRegionInfo::eYes);
483     regions.push_back(region);
484   }
485   regions.shrink_to_fit();
486   return !regions.empty();
487 }
488 
489 static bool
490 CreateRegionsCacheFromMemory64List(MinidumpParser &parser,
491                                    std::vector<MemoryRegionInfo> &regions) {
492   llvm::ArrayRef<uint8_t> data =
493       parser.GetStream(StreamType::Memory64List);
494   if (data.empty())
495     return false;
496   llvm::ArrayRef<MinidumpMemoryDescriptor64> memory64_list;
497   uint64_t base_rva;
498   std::tie(memory64_list, base_rva) =
499       MinidumpMemoryDescriptor64::ParseMemory64List(data);
500 
501   if (memory64_list.empty())
502     return false;
503 
504   regions.reserve(memory64_list.size());
505   for (const auto &memory_desc : memory64_list) {
506     if (memory_desc.data_size == 0)
507       continue;
508     MemoryRegionInfo region;
509     region.GetRange().SetRangeBase(memory_desc.start_of_memory_range);
510     region.GetRange().SetByteSize(memory_desc.data_size);
511     region.SetReadable(MemoryRegionInfo::eYes);
512     region.SetMapped(MemoryRegionInfo::eYes);
513     regions.push_back(region);
514   }
515   regions.shrink_to_fit();
516   return !regions.empty();
517 }
518 
519 MemoryRegionInfo
520 MinidumpParser::FindMemoryRegion(lldb::addr_t load_addr) const {
521   auto begin = m_regions.begin();
522   auto end = m_regions.end();
523   auto pos = std::lower_bound(begin, end, load_addr);
524   if (pos != end && pos->GetRange().Contains(load_addr))
525     return *pos;
526 
527   MemoryRegionInfo region;
528   if (pos == begin)
529     region.GetRange().SetRangeBase(0);
530   else {
531     auto prev = pos - 1;
532     if (prev->GetRange().Contains(load_addr))
533       return *prev;
534     region.GetRange().SetRangeBase(prev->GetRange().GetRangeEnd());
535   }
536   if (pos == end)
537     region.GetRange().SetRangeEnd(UINT64_MAX);
538   else
539     region.GetRange().SetRangeEnd(pos->GetRange().GetRangeBase());
540   region.SetReadable(MemoryRegionInfo::eNo);
541   region.SetWritable(MemoryRegionInfo::eNo);
542   region.SetExecutable(MemoryRegionInfo::eNo);
543   region.SetMapped(MemoryRegionInfo::eNo);
544   return region;
545 }
546 
547 MemoryRegionInfo
548 MinidumpParser::GetMemoryRegionInfo(lldb::addr_t load_addr) {
549   if (!m_parsed_regions)
550     GetMemoryRegions();
551   return FindMemoryRegion(load_addr);
552 }
553 
554 const MemoryRegionInfos &MinidumpParser::GetMemoryRegions() {
555   if (!m_parsed_regions) {
556     m_parsed_regions = true;
557     // We haven't cached our memory regions yet we will create the region cache
558     // once. We create the region cache using the best source. We start with
559     // the linux maps since they are the most complete and have names for the
560     // regions. Next we try the MemoryInfoList since it has
561     // read/write/execute/map data, and then fall back to the MemoryList and
562     // Memory64List to just get a list of the memory that is mapped in this
563     // core file
564     if (!CreateRegionsCacheFromLinuxMaps(*this, m_regions))
565       if (!CreateRegionsCacheFromMemoryInfoList(*this, m_regions))
566         if (!CreateRegionsCacheFromMemoryList(*this, m_regions))
567           CreateRegionsCacheFromMemory64List(*this, m_regions);
568     llvm::sort(m_regions.begin(), m_regions.end());
569   }
570   return m_regions;
571 }
572 
573 #define ENUM_TO_CSTR(ST)                                                       \
574   case StreamType::ST:                                                         \
575     return #ST
576 
577 llvm::StringRef
578 MinidumpParser::GetStreamTypeAsString(StreamType stream_type) {
579   switch (stream_type) {
580     ENUM_TO_CSTR(Unused);
581     ENUM_TO_CSTR(ThreadList);
582     ENUM_TO_CSTR(ModuleList);
583     ENUM_TO_CSTR(MemoryList);
584     ENUM_TO_CSTR(Exception);
585     ENUM_TO_CSTR(SystemInfo);
586     ENUM_TO_CSTR(ThreadExList);
587     ENUM_TO_CSTR(Memory64List);
588     ENUM_TO_CSTR(CommentA);
589     ENUM_TO_CSTR(CommentW);
590     ENUM_TO_CSTR(HandleData);
591     ENUM_TO_CSTR(FunctionTable);
592     ENUM_TO_CSTR(UnloadedModuleList);
593     ENUM_TO_CSTR(MiscInfo);
594     ENUM_TO_CSTR(MemoryInfoList);
595     ENUM_TO_CSTR(ThreadInfoList);
596     ENUM_TO_CSTR(HandleOperationList);
597     ENUM_TO_CSTR(Token);
598     ENUM_TO_CSTR(JavascriptData);
599     ENUM_TO_CSTR(SystemMemoryInfo);
600     ENUM_TO_CSTR(ProcessVMCounters);
601     ENUM_TO_CSTR(LastReserved);
602     ENUM_TO_CSTR(BreakpadInfo);
603     ENUM_TO_CSTR(AssertionInfo);
604     ENUM_TO_CSTR(LinuxCPUInfo);
605     ENUM_TO_CSTR(LinuxProcStatus);
606     ENUM_TO_CSTR(LinuxLSBRelease);
607     ENUM_TO_CSTR(LinuxCMDLine);
608     ENUM_TO_CSTR(LinuxEnviron);
609     ENUM_TO_CSTR(LinuxAuxv);
610     ENUM_TO_CSTR(LinuxMaps);
611     ENUM_TO_CSTR(LinuxDSODebug);
612     ENUM_TO_CSTR(LinuxProcStat);
613     ENUM_TO_CSTR(LinuxProcUptime);
614     ENUM_TO_CSTR(LinuxProcFD);
615     ENUM_TO_CSTR(FacebookAppCustomData);
616     ENUM_TO_CSTR(FacebookBuildID);
617     ENUM_TO_CSTR(FacebookAppVersionName);
618     ENUM_TO_CSTR(FacebookJavaStack);
619     ENUM_TO_CSTR(FacebookDalvikInfo);
620     ENUM_TO_CSTR(FacebookUnwindSymbols);
621     ENUM_TO_CSTR(FacebookDumpErrorLog);
622     ENUM_TO_CSTR(FacebookAppStateLog);
623     ENUM_TO_CSTR(FacebookAbortReason);
624     ENUM_TO_CSTR(FacebookThreadName);
625     ENUM_TO_CSTR(FacebookLogcat);
626   }
627   return "unknown stream type";
628 }
629