utils.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. const prettySymbolType = PRETTY_SYMBOL_TYPES[symbolType] ?? symbolType;
  29. const prettyFileType = PRETTY_FILE_TYPES[data?.type ?? '_'];
  30. const prettyCpuName =
  31. cpuName && cpuName !== 'any' && cpuName !== 'unknown' ? `(${cpuName})` : null;
  32. return [prettySymbolType, prettyFileType, prettyCpuName].filter(Boolean).join(' ');
  33. }
  34. export function getFeatureTooltip(feature: DebugFileFeature) {
  35. switch (feature) {
  36. case DebugFileFeature.SYMTAB:
  37. return t(
  38. 'Symbol tables are used as a fallback when full debug information is not available'
  39. );
  40. case DebugFileFeature.DEBUG:
  41. return t(
  42. 'Debug information provides function names and resolves inlined frames during symbolication'
  43. );
  44. case DebugFileFeature.UNWIND:
  45. return t(
  46. 'Stack unwinding information improves the quality of stack traces extracted from minidumps'
  47. );
  48. case DebugFileFeature.SOURCES:
  49. return t(
  50. 'Source code information allows Sentry to display source code context for stack frames'
  51. );
  52. default:
  53. return null;
  54. }
  55. }