stack_frame.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef EXTENSIONS_COMMON_STACK_FRAME_H_
  5. #define EXTENSIONS_COMMON_STACK_FRAME_H_
  6. #include <stddef.h>
  7. #include <memory>
  8. #include <string>
  9. #include <vector>
  10. namespace extensions {
  11. struct StackFrame {
  12. StackFrame();
  13. StackFrame(const StackFrame& frame);
  14. StackFrame(uint32_t line_number,
  15. uint32_t column_number,
  16. const std::u16string& source,
  17. const std::u16string& function);
  18. ~StackFrame();
  19. // Construct a stack frame from a reported plain-text frame.
  20. static std::unique_ptr<StackFrame> CreateFromText(
  21. const std::u16string& frame_text);
  22. bool operator==(const StackFrame& rhs) const;
  23. // Note: we use uint32_t instead of size_t because this struct is sent over
  24. // IPC which could span 32 & 64 bit processes. This is fine since line numbers
  25. // and column numbers shouldn't exceed UINT32_MAX even on 64 bit builds.
  26. uint32_t line_number;
  27. uint32_t column_number;
  28. std::u16string source;
  29. std::u16string function; // optional
  30. };
  31. typedef std::vector<StackFrame> StackTrace;
  32. } // namespace extensions
  33. #endif // EXTENSIONS_COMMON_STACK_FRAME_H_