utils.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {t} from 'sentry/locale';
  2. import {DebugFile, DebugFileFeature, DebugFileType} from 'sentry/types/debugFiles';
  3. const PRETTY_SYMBOL_TYPES = {
  4. proguard: t('ProGuard mapping'),
  5. breakpad: t('Breadpad'),
  6. macho: t('Mach-O'),
  7. elf: t('ELF'),
  8. pe: t('PE'),
  9. pdb: t('PDB'),
  10. portablepdb: t('Portable PDB'),
  11. sourcebundle: t('SourceBundle'),
  12. wasm: t('WebAssembly'),
  13. bcsymbolmap: t('BCSymbolMap'),
  14. il2cpp: t('IL2CPP mapping'),
  15. };
  16. const PRETTY_FILE_TYPES = {
  17. [DebugFileType.EXE]: t('executable'),
  18. [DebugFileType.DBG]: t('debug companion'),
  19. [DebugFileType.LIB]: t('dynamic library'),
  20. };
  21. /**
  22. * Give a pretty human-readable description of a `DebugFile`.
  23. * For example "ELF dynamic library (x86_64)"
  24. */
  25. export function getPrettyFileType(dsym: DebugFile) {
  26. const {symbolType, data, cpuName} = dsym;
  27. const prettySymbolType = PRETTY_SYMBOL_TYPES[symbolType] ?? symbolType;
  28. const prettyFileType = PRETTY_FILE_TYPES[data?.type ?? '_'];
  29. const prettyCpuName =
  30. cpuName && cpuName !== 'any' && cpuName !== 'unknown' ? `(${cpuName})` : null;
  31. return [prettySymbolType, prettyFileType, prettyCpuName].filter(Boolean).join(' ');
  32. }
  33. export function getFeatureTooltip(feature: DebugFileFeature) {
  34. switch (feature) {
  35. case DebugFileFeature.SYMTAB:
  36. return t(
  37. 'Symbol tables are used as a fallback when full debug information is not available'
  38. );
  39. case DebugFileFeature.DEBUG:
  40. return t(
  41. 'Debug information provides function names and resolves inlined frames during symbolication'
  42. );
  43. case DebugFileFeature.UNWIND:
  44. return t(
  45. 'Stack unwinding information improves the quality of stack traces extracted from minidumps'
  46. );
  47. case DebugFileFeature.SOURCES:
  48. return t(
  49. 'Source code information allows Sentry to display source code context for stack frames'
  50. );
  51. default:
  52. return null;
  53. }
  54. }