From 2f9a023d69c3fb336d71ca5953dad5f36f265237 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Wed, 25 Nov 2020 00:00:09 +0100 Subject: [PATCH 1/5] feat(protocol): Add protocol support for WASM --- relay-general/src/protocol/debugmeta.rs | 4 ++-- relay-general/src/protocol/stacktrace.rs | 10 ++++++++- .../test_fixtures__event_schema.snap | 21 ++++++++++++++++--- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/relay-general/src/protocol/debugmeta.rs b/relay-general/src/protocol/debugmeta.rs index f1f1e2287da..8d7f1a66d43 100644 --- a/relay-general/src/protocol/debugmeta.rs +++ b/relay-general/src/protocol/debugmeta.rs @@ -377,13 +377,11 @@ pub struct NativeDebugImage { /// Starting memory address of the image (required). /// /// Memory address, at which the image is mounted in the virtual address space of the process. Should be a string in hex representation prefixed with `"0x"`. - #[metastructure(required = "true")] pub image_addr: Annotated, /// Size of the image in bytes (required). /// /// The size of the image in virtual memory. If missing, Sentry will assume that the image spans up to the next image, which might lead to invalid stack traces. - #[metastructure(required = "true")] pub image_size: Annotated, /// Loading address in virtual memory. @@ -436,6 +434,8 @@ pub enum DebugImage { Pe(Box), /// A reference to a proguard debug file. Proguard(Box), + /// WASM debug image. + Wasm(Box), /// A debug image that is unknown to this protocol specification. #[metastructure(fallback_variant)] Other(Object), diff --git a/relay-general/src/protocol/stacktrace.rs b/relay-general/src/protocol/stacktrace.rs index 95fbab129c3..9188b6188a2 100644 --- a/relay-general/src/protocol/stacktrace.rs +++ b/relay-general/src/protocol/stacktrace.rs @@ -1,6 +1,6 @@ use std::ops::{Deref, DerefMut}; -use crate::protocol::{Addr, NativeImagePath, RegVal}; +use crate::protocol::{Addr, DebugId, NativeImagePath, RegVal}; use crate::types::{Annotated, Array, FromValue, Object, Value}; /// Holds information about a single stacktrace frame. @@ -126,6 +126,10 @@ pub struct Frame { /// then symbolication can take place. pub instruction_addr: Annotated, + /// When provided switches `instruction_addr` to be relative within + /// a specific image. + pub in_image: Annotated, + /// (C/C++/Native) Start address of the frame's function. /// /// We use the instruction address for symbolication, but this can be used to calculate @@ -361,6 +365,7 @@ fn test_frame_roundtrip() { }, "image_addr": "0x400", "instruction_addr": "0x404", + "in_image": "f3283016-637c-463b-8b3e-46eda376c9dd", "symbol_addr": "0x404", "trust": "69", "lang": "rust", @@ -395,6 +400,9 @@ fn test_frame_roundtrip() { }), image_addr: Annotated::new(Addr(0x400)), instruction_addr: Annotated::new(Addr(0x404)), + in_image: Annotated::new(DebugId( + "f3283016-637c-463b-8b3e-46eda376c9dd".parse().unwrap(), + )), symbol_addr: Annotated::new(Addr(0x404)), trust: Annotated::new("69".into()), lang: Annotated::new("rust".into()), diff --git a/relay-general/tests/snapshots/test_fixtures__event_schema.snap b/relay-general/tests/snapshots/test_fixtures__event_schema.snap index 3c96fb8136b..dbddea789eb 100644 --- a/relay-general/tests/snapshots/test_fixtures__event_schema.snap +++ b/relay-general/tests/snapshots/test_fixtures__event_schema.snap @@ -877,6 +877,9 @@ expression: event_json_schema() { "$ref": "#/definitions/ProguardDebugImage" }, + { + "$ref": "#/definitions/NativeDebugImage" + }, { "type": "object", "additionalProperties": true @@ -1366,6 +1369,18 @@ expression: event_json_schema() "null" ] }, + "in_image": { + "description": " When provided switches `instruction_addr` to be relative within\n a specific image.", + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/DebugId" + }, + { + "type": "null" + } + ] + }, "instruction_addr": { "description": " (C/C++/Native) An optional instruction address for symbolication.\n\n This should be a string with a hexadecimal number that includes a 0x prefix.\n If this is set and a known image is defined in the\n [Debug Meta Interface]({%- link _documentation/development/sdk-dev/event-payloads/debugmeta.md -%}),\n then symbolication can take place.", "default": null, @@ -1924,9 +1939,7 @@ expression: event_json_schema() "type": "object", "required": [ "code_file", - "debug_id", - "image_addr", - "image_size" + "debug_id" ], "properties": { "arch": { @@ -1985,6 +1998,7 @@ expression: event_json_schema() }, "image_addr": { "description": " Starting memory address of the image (required).\n\n Memory address, at which the image is mounted in the virtual address space of the process. Should be a string in hex representation prefixed with `\"0x\"`.", + "default": null, "anyOf": [ { "$ref": "#/definitions/Addr" @@ -1996,6 +2010,7 @@ expression: event_json_schema() }, "image_size": { "description": " Size of the image in bytes (required).\n\n The size of the image in virtual memory. If missing, Sentry will assume that the image spans up to the next image, which might lead to invalid stack traces.", + "default": null, "type": [ "integer", "null" From a5b6d703c4dc4b8603f502c750c103e3c48f89eb Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 26 Nov 2020 14:27:01 +0100 Subject: [PATCH 2/5] ref: in_image -> addr_mode --- relay-general/src/protocol/stacktrace.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/relay-general/src/protocol/stacktrace.rs b/relay-general/src/protocol/stacktrace.rs index 9188b6188a2..1dcce5b1c8f 100644 --- a/relay-general/src/protocol/stacktrace.rs +++ b/relay-general/src/protocol/stacktrace.rs @@ -126,9 +126,8 @@ pub struct Frame { /// then symbolication can take place. pub instruction_addr: Annotated, - /// When provided switches `instruction_addr` to be relative within - /// a specific image. - pub in_image: Annotated, + /// Defines the addressing mode for addresses. + pub addr_mode: Annotated, /// (C/C++/Native) Start address of the frame's function. /// @@ -365,7 +364,7 @@ fn test_frame_roundtrip() { }, "image_addr": "0x400", "instruction_addr": "0x404", - "in_image": "f3283016-637c-463b-8b3e-46eda376c9dd", + "addr_mode": "abs", "symbol_addr": "0x404", "trust": "69", "lang": "rust", @@ -400,9 +399,7 @@ fn test_frame_roundtrip() { }), image_addr: Annotated::new(Addr(0x400)), instruction_addr: Annotated::new(Addr(0x404)), - in_image: Annotated::new(DebugId( - "f3283016-637c-463b-8b3e-46eda376c9dd".parse().unwrap(), - )), + addr_mode: Annotated::new("abs".into()), symbol_addr: Annotated::new(Addr(0x404)), trust: Annotated::new("69".into()), lang: Annotated::new("rust".into()), From c4b7832542ee6d3870cb6e684fc5800eacadcc22 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 26 Nov 2020 14:28:43 +0100 Subject: [PATCH 3/5] ref: Update schema --- .../test_fixtures__event_schema.snap | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/relay-general/tests/snapshots/test_fixtures__event_schema.snap b/relay-general/tests/snapshots/test_fixtures__event_schema.snap index dbddea789eb..90097b671d6 100644 --- a/relay-general/tests/snapshots/test_fixtures__event_schema.snap +++ b/relay-general/tests/snapshots/test_fixtures__event_schema.snap @@ -1311,6 +1311,14 @@ expression: event_json_schema() } ] }, + "addr_mode": { + "description": " Defines the addressing mode for addresses.", + "default": null, + "type": [ + "string", + "null" + ] + }, "colno": { "description": " Column number within the source file, starting at 1.", "default": null, @@ -1369,18 +1377,6 @@ expression: event_json_schema() "null" ] }, - "in_image": { - "description": " When provided switches `instruction_addr` to be relative within\n a specific image.", - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/DebugId" - }, - { - "type": "null" - } - ] - }, "instruction_addr": { "description": " (C/C++/Native) An optional instruction address for symbolication.\n\n This should be a string with a hexadecimal number that includes a 0x prefix.\n If this is set and a known image is defined in the\n [Debug Meta Interface]({%- link _documentation/development/sdk-dev/event-payloads/debugmeta.md -%}),\n then symbolication can take place.", "default": null, From 6cf76cb0b23ef39afc0b8b6a461e56aadfc673f1 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 26 Nov 2020 14:44:17 +0100 Subject: [PATCH 4/5] fix: clippy --- relay-general/src/protocol/stacktrace.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relay-general/src/protocol/stacktrace.rs b/relay-general/src/protocol/stacktrace.rs index 1dcce5b1c8f..531356002ed 100644 --- a/relay-general/src/protocol/stacktrace.rs +++ b/relay-general/src/protocol/stacktrace.rs @@ -1,6 +1,6 @@ use std::ops::{Deref, DerefMut}; -use crate::protocol::{Addr, DebugId, NativeImagePath, RegVal}; +use crate::protocol::{Addr, NativeImagePath, RegVal}; use crate::types::{Annotated, Array, FromValue, Object, Value}; /// Holds information about a single stacktrace frame. From 8a822f3fbbd6ccd6b58cb065ae9095f6a5eaf9f1 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Thu, 26 Nov 2020 14:46:19 +0100 Subject: [PATCH 5/5] fix: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 352c2f1b6a7..719e78e9712 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ **Features**: - Relay is now able to ingest pre-aggregated sessions, which will make it possible to efficiently handle applications that produce thousands of sessions per second. ([#815](https://github.com/getsentry/relay/pull/815)) +- Add protocol support for WASM. ([#852](https://github.com/getsentry/relay/pull/852)) **Bug Fixes**: