Skip to content

Commit 775dae8

Browse files
authored
ref(gnu-integration): make path optional (#4688)
I updated the GNU Integration in #4598 but I didn't make the path optional so if we didn't have the path included, then the stacktrace didn't get parsed: ```python # got parsed "17. DB::TCPHandler::runImpl() @ 0x00000000121bb5d8 in /usr/bin/clickhouse" # didn't get parsed "17. DB::TCPHandler::runImpl() @ 0x00000000121bb5d8" ``` So updated it so that regardless of whether the path is present it will get parsed
1 parent 0dc5d43 commit 775dae8

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

sentry_sdk/integrations/gnu_backtrace.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
1111
from typing import Any
1212
from sentry_sdk._types import Event
1313

14-
15-
FUNCTION_RE = r"[^@]+?)\s+@\s+0x[0-9a-fA-F]+"
14+
# function is everything between index at @
15+
# and then we match on the @ plus the hex val
16+
FUNCTION_RE = r"[^@]+?"
17+
HEX_ADDRESS = r"\s+@\s+0x[0-9a-fA-F]+"
1618

1719
FRAME_RE = r"""
18-
^(?P<index>\d+)\.\s+(?P<function>{FUNCTION_RE}\s+in\s+(?P<package>.+)$
20+
^(?P<index>\d+)\.\s+(?P<function>{FUNCTION_RE}){HEX_ADDRESS}(?:\s+in\s+(?P<package>.+))?$
1921
""".format(
2022
FUNCTION_RE=FUNCTION_RE,
23+
HEX_ADDRESS=HEX_ADDRESS,
2124
)
2225

2326
FRAME_RE = re.compile(FRAME_RE, re.MULTILINE | re.VERBOSE)

tests/integrations/test_gnu_backtrace.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,38 @@
3131
24. ? @ 0x00000000000d162c in /usr/lib/aarch64-linux-gnu/libc-2.31.so
3232
"""
3333

34+
LINES_NO_PATH = r"""
35+
0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000bfc38a4
36+
1. DB::Exception::Exception<String, String>(int, FormatStringHelperImpl<std::type_identity<String>::type, std::type_identity<String>::type>, String&&, String&&) @ 0x00000000075d242c
37+
2. DB::ActionsMatcher::visit(DB::ASTIdentifier const&, std::shared_ptr<DB::IAST> const&, DB::ActionsMatcher::Data&) @ 0x0000000010b1c648
38+
3. DB::ActionsMatcher::visit(DB::ASTFunction const&, std::shared_ptr<DB::IAST> const&, DB::ActionsMatcher::Data&) @ 0x0000000010b1f58c
39+
4. DB::ActionsMatcher::visit(DB::ASTFunction const&, std::shared_ptr<DB::IAST> const&, DB::ActionsMatcher::Data&) @ 0x0000000010b1f58c
40+
5. DB::ActionsMatcher::visit(std::shared_ptr<DB::IAST> const&, DB::ActionsMatcher::Data&) @ 0x0000000010b1c394
41+
6. DB::InDepthNodeVisitor<DB::ActionsMatcher, true, false, std::shared_ptr<DB::IAST> const>::doVisit(std::shared_ptr<DB::IAST> const&) @ 0x0000000010b154a0
42+
7. DB::ExpressionAnalyzer::getRootActions(std::shared_ptr<DB::IAST> const&, bool, std::shared_ptr<DB::ActionsDAG>&, bool) @ 0x0000000010af83b4
43+
8. DB::SelectQueryExpressionAnalyzer::appendSelect(DB::ExpressionActionsChain&, bool) @ 0x0000000010aff168
44+
9. DB::ExpressionAnalysisResult::ExpressionAnalysisResult(DB::SelectQueryExpressionAnalyzer&, std::shared_ptr<DB::StorageInMemoryMetadata const> const&, bool, bool, bool, std::shared_ptr<DB::FilterDAGInfo> const&, std::shared_ptr<DB::FilterDAGInfo> const&, DB::Block const&) @ 0x0000000010b05b74
45+
10. DB::InterpreterSelectQuery::getSampleBlockImpl() @ 0x00000000111559fc
46+
11. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context> const&, std::optional<DB::Pipe>, std::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions const&, std::vector<String, std::allocator<String>> const&, std::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::shared_ptr<DB::PreparedSets>)::$_0::operator()(bool) const @ 0x0000000011148254
47+
12. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context> const&, std::optional<DB::Pipe>, std::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions const&, std::vector<String, std::allocator<String>> const&, std::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::shared_ptr<DB::PreparedSets>) @ 0x00000000111413e8
48+
13. DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context>, DB::SelectQueryOptions const&, std::vector<String, std::allocator<String>> const&) @ 0x00000000111d3708
49+
14. DB::InterpreterFactory::get(std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::Context>, DB::SelectQueryOptions const&) @ 0x0000000011100b64
50+
15. DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x00000000114c3f3c
51+
16. DB::executeQuery(String const&, std::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) @ 0x00000000114c0ec8
52+
17. DB::TCPHandler::runImpl() @ 0x00000000121bb5d8
53+
18. DB::TCPHandler::run() @ 0x00000000121cb728
54+
19. Poco::Net::TCPServerConnection::start() @ 0x00000000146d9404
55+
20. Poco::Net::TCPServerDispatcher::run() @ 0x00000000146da900
56+
21. Poco::PooledThread::run() @ 0x000000001484da7c
57+
22. Poco::ThreadImpl::runnableEntry(void*) @ 0x000000001484bc24
58+
23. start_thread @ 0x0000000000007624
59+
24. ? @ 0x00000000000d162c
60+
"""
61+
3462

35-
@pytest.mark.parametrize("input", LINES.strip().splitlines())
63+
@pytest.mark.parametrize(
64+
"input", LINES.strip().splitlines() + LINES_NO_PATH.strip().splitlines()
65+
)
3666
def test_basic(sentry_init, capture_events, input):
3767
sentry_init(integrations=[GnuBacktraceIntegration()])
3868
events = capture_events()

0 commit comments

Comments
 (0)