utils.tsx 2.2 KB

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