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 minidump::ExceptionStream *MinidumpParser::GetExceptionStream() {
318   auto ExpectedStream = GetMinidumpFile().getExceptionStream();
319   if (ExpectedStream)
320     return &*ExpectedStream;
321 
322   LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS),
323                  ExpectedStream.takeError(),
324                  "Failed to read minidump exception stream: {0}");
325   return nullptr;
326 }
327 
328 llvm::Optional<minidump::Range>
329 MinidumpParser::FindMemoryRange(lldb::addr_t addr) {
330   llvm::ArrayRef<uint8_t> data64 = GetStream(StreamType::Memory64List);
331   Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
332 
333   auto ExpectedMemory = GetMinidumpFile().getMemoryList();
334   if (!ExpectedMemory) {
335     LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
336                    "Failed to read memory list: {0}");
337   } else {
338     for (const auto &memory_desc : *ExpectedMemory) {
339       const LocationDescriptor &loc_desc = memory_desc.Memory;
340       const lldb::addr_t range_start = memory_desc.StartOfMemoryRange;
341       const size_t range_size = loc_desc.DataSize;
342 
343       if (loc_desc.RVA + loc_desc.DataSize > GetData().size())
344         return llvm::None;
345 
346       if (range_start <= addr && addr < range_start + range_size) {
347         auto ExpectedSlice = GetMinidumpFile().getRawData(loc_desc);
348         if (!ExpectedSlice) {
349           LLDB_LOG_ERROR(log, ExpectedSlice.takeError(),
350                          "Failed to get memory slice: {0}");
351           return llvm::None;
352         }
353         return minidump::Range(range_start, *ExpectedSlice);
354       }
355     }
356   }
357 
358   // Some Minidumps have a Memory64ListStream that captures all the heap memory
359   // (full-memory Minidumps).  We can't exactly use the same loop as above,
360   // because the Minidump uses slightly different data structures to describe
361   // those
362 
363   if (!data64.empty()) {
364     llvm::ArrayRef<MinidumpMemoryDescriptor64> memory64_list;
365     uint64_t base_rva;
366     std::tie(memory64_list, base_rva) =
367         MinidumpMemoryDescriptor64::ParseMemory64List(data64);
368 
369     if (memory64_list.empty())
370       return llvm::None;
371 
372     for (const auto &memory_desc64 : memory64_list) {
373       const lldb::addr_t range_start = memory_desc64.start_of_memory_range;
374       const size_t range_size = memory_desc64.data_size;
375 
376       if (base_rva + range_size > GetData().size())
377         return llvm::None;
378 
379       if (range_start <= addr && addr < range_start + range_size) {
380         return minidump::Range(range_start,
381                                GetData().slice(base_rva, range_size));
382       }
383       base_rva += range_size;
384     }
385   }
386 
387   return llvm::None;
388 }
389 
390 llvm::ArrayRef<uint8_t> MinidumpParser::GetMemory(lldb::addr_t addr,
391                                                   size_t size) {
392   // I don't have a sense of how frequently this is called or how many memory
393   // ranges a Minidump typically has, so I'm not sure if searching for the
394   // appropriate range linearly each time is stupid.  Perhaps we should build
395   // an index for faster lookups.
396   llvm::Optional<minidump::Range> range = FindMemoryRange(addr);
397   if (!range)
398     return {};
399 
400   // There's at least some overlap between the beginning of the desired range
401   // (addr) and the current range.  Figure out where the overlap begins and how
402   // much overlap there is.
403 
404   const size_t offset = addr - range->start;
405 
406   if (addr < range->start || offset >= range->range_ref.size())
407     return {};
408 
409   const size_t overlap = std::min(size, range->range_ref.size() - offset);
410   return range->range_ref.slice(offset, overlap);
411 }
412 
413 static bool
414 CreateRegionsCacheFromLinuxMaps(MinidumpParser &parser,
415                                 std::vector<MemoryRegionInfo> &regions) {
416   auto data = parser.GetStream(StreamType::LinuxMaps);
417   if (data.empty())
418     return false;
419   ParseLinuxMapRegions(llvm::toStringRef(data),
420                        [&](const lldb_private::MemoryRegionInfo &region,
421                            const lldb_private::Status &status) -> bool {
422     if (status.Success())
423       regions.push_back(region);
424     return true;
425   });
426   return !regions.empty();
427 }
428 
429 static bool
430 CreateRegionsCacheFromMemoryInfoList(MinidumpParser &parser,
431                                      std::vector<MemoryRegionInfo> &regions) {
432   Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
433   auto ExpectedInfo = parser.GetMinidumpFile().getMemoryInfoList();
434   if (!ExpectedInfo) {
435     LLDB_LOG_ERROR(log, ExpectedInfo.takeError(),
436                    "Failed to read memory info list: {0}");
437     return false;
438   }
439   constexpr auto yes = MemoryRegionInfo::eYes;
440   constexpr auto no = MemoryRegionInfo::eNo;
441   for (const MemoryInfo &entry : *ExpectedInfo) {
442     MemoryRegionInfo region;
443     region.GetRange().SetRangeBase(entry.BaseAddress);
444     region.GetRange().SetByteSize(entry.RegionSize);
445 
446     MemoryProtection prot = entry.Protect;
447     region.SetReadable(bool(prot & MemoryProtection::NoAccess) ? no : yes);
448     region.SetWritable(
449         bool(prot & (MemoryProtection::ReadWrite | MemoryProtection::WriteCopy |
450                      MemoryProtection::ExecuteReadWrite |
451                      MemoryProtection::ExeciteWriteCopy))
452             ? yes
453             : no);
454     region.SetExecutable(
455         bool(prot & (MemoryProtection::Execute | MemoryProtection::ExecuteRead |
456                      MemoryProtection::ExecuteReadWrite |
457                      MemoryProtection::ExeciteWriteCopy))
458             ? yes
459             : no);
460     region.SetMapped(entry.State != MemoryState::Free ? yes : no);
461     regions.push_back(region);
462   }
463   return !regions.empty();
464 }
465 
466 static bool
467 CreateRegionsCacheFromMemoryList(MinidumpParser &parser,
468                                  std::vector<MemoryRegionInfo> &regions) {
469   Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
470   auto ExpectedMemory = parser.GetMinidumpFile().getMemoryList();
471   if (!ExpectedMemory) {
472     LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
473                    "Failed to read memory list: {0}");
474     return false;
475   }
476   regions.reserve(ExpectedMemory->size());
477   for (const MemoryDescriptor &memory_desc : *ExpectedMemory) {
478     if (memory_desc.Memory.DataSize == 0)
479       continue;
480     MemoryRegionInfo region;
481     region.GetRange().SetRangeBase(memory_desc.StartOfMemoryRange);
482     region.GetRange().SetByteSize(memory_desc.Memory.DataSize);
483     region.SetReadable(MemoryRegionInfo::eYes);
484     region.SetMapped(MemoryRegionInfo::eYes);
485     regions.push_back(region);
486   }
487   regions.shrink_to_fit();
488   return !regions.empty();
489 }
490 
491 static bool
492 CreateRegionsCacheFromMemory64List(MinidumpParser &parser,
493                                    std::vector<MemoryRegionInfo> &regions) {
494   llvm::ArrayRef<uint8_t> data =
495       parser.GetStream(StreamType::Memory64List);
496   if (data.empty())
497     return false;
498   llvm::ArrayRef<MinidumpMemoryDescriptor64> memory64_list;
499   uint64_t base_rva;
500   std::tie(memory64_list, base_rva) =
501       MinidumpMemoryDescriptor64::ParseMemory64List(data);
502 
503   if (memory64_list.empty())
504     return false;
505 
506   regions.reserve(memory64_list.size());
507   for (const auto &memory_desc : memory64_list) {
508     if (memory_desc.data_size == 0)
509       continue;
510     MemoryRegionInfo region;
511     region.GetRange().SetRangeBase(memory_desc.start_of_memory_range);
512     region.GetRange().SetByteSize(memory_desc.data_size);
513     region.SetReadable(MemoryRegionInfo::eYes);
514     region.SetMapped(MemoryRegionInfo::eYes);
515     regions.push_back(region);
516   }
517   regions.shrink_to_fit();
518   return !regions.empty();
519 }
520 
521 std::pair<MemoryRegionInfos, bool> MinidumpParser::BuildMemoryRegions() {
522   // We create the region cache using the best source. We start with
523   // the linux maps since they are the most complete and have names for the
524   // regions. Next we try the MemoryInfoList since it has
525   // read/write/execute/map data, and then fall back to the MemoryList and
526   // Memory64List to just get a list of the memory that is mapped in this
527   // core file
528   MemoryRegionInfos result;
529   const auto &return_sorted = [&](bool is_complete) {
530     llvm::sort(result);
531     return std::make_pair(std::move(result), is_complete);
532   };
533   if (CreateRegionsCacheFromLinuxMaps(*this, result))
534     return return_sorted(true);
535   if (CreateRegionsCacheFromMemoryInfoList(*this, result))
536     return return_sorted(true);
537   if (CreateRegionsCacheFromMemoryList(*this, result))
538     return return_sorted(false);
539   CreateRegionsCacheFromMemory64List(*this, result);
540   return return_sorted(false);
541 }
542 
543 #define ENUM_TO_CSTR(ST)                                                       \
544   case StreamType::ST:                                                         \
545     return #ST
546 
547 llvm::StringRef
548 MinidumpParser::GetStreamTypeAsString(StreamType stream_type) {
549   switch (stream_type) {
550     ENUM_TO_CSTR(Unused);
551     ENUM_TO_CSTR(ThreadList);
552     ENUM_TO_CSTR(ModuleList);
553     ENUM_TO_CSTR(MemoryList);
554     ENUM_TO_CSTR(Exception);
555     ENUM_TO_CSTR(SystemInfo);
556     ENUM_TO_CSTR(ThreadExList);
557     ENUM_TO_CSTR(Memory64List);
558     ENUM_TO_CSTR(CommentA);
559     ENUM_TO_CSTR(CommentW);
560     ENUM_TO_CSTR(HandleData);
561     ENUM_TO_CSTR(FunctionTable);
562     ENUM_TO_CSTR(UnloadedModuleList);
563     ENUM_TO_CSTR(MiscInfo);
564     ENUM_TO_CSTR(MemoryInfoList);
565     ENUM_TO_CSTR(ThreadInfoList);
566     ENUM_TO_CSTR(HandleOperationList);
567     ENUM_TO_CSTR(Token);
568     ENUM_TO_CSTR(JavascriptData);
569     ENUM_TO_CSTR(SystemMemoryInfo);
570     ENUM_TO_CSTR(ProcessVMCounters);
571     ENUM_TO_CSTR(LastReserved);
572     ENUM_TO_CSTR(BreakpadInfo);
573     ENUM_TO_CSTR(AssertionInfo);
574     ENUM_TO_CSTR(LinuxCPUInfo);
575     ENUM_TO_CSTR(LinuxProcStatus);
576     ENUM_TO_CSTR(LinuxLSBRelease);
577     ENUM_TO_CSTR(LinuxCMDLine);
578     ENUM_TO_CSTR(LinuxEnviron);
579     ENUM_TO_CSTR(LinuxAuxv);
580     ENUM_TO_CSTR(LinuxMaps);
581     ENUM_TO_CSTR(LinuxDSODebug);
582     ENUM_TO_CSTR(LinuxProcStat);
583     ENUM_TO_CSTR(LinuxProcUptime);
584     ENUM_TO_CSTR(LinuxProcFD);
585     ENUM_TO_CSTR(FacebookAppCustomData);
586     ENUM_TO_CSTR(FacebookBuildID);
587     ENUM_TO_CSTR(FacebookAppVersionName);
588     ENUM_TO_CSTR(FacebookJavaStack);
589     ENUM_TO_CSTR(FacebookDalvikInfo);
590     ENUM_TO_CSTR(FacebookUnwindSymbols);
591     ENUM_TO_CSTR(FacebookDumpErrorLog);
592     ENUM_TO_CSTR(FacebookAppStateLog);
593     ENUM_TO_CSTR(FacebookAbortReason);
594     ENUM_TO_CSTR(FacebookThreadName);
595     ENUM_TO_CSTR(FacebookLogcat);
596   }
597   return "unknown stream type";
598 }
599