-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[lldb] Support specifying a language for breakpoint conditions #147603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLDB_BREAKPOINT_STOPCONDITION_H | ||
#define LLDB_BREAKPOINT_STOPCONDITION_H | ||
|
||
#include "lldb/lldb-private.h" | ||
#include "llvm/ADT/StringRef.h" | ||
|
||
namespace lldb_private { | ||
|
||
class StopCondition { | ||
public: | ||
StopCondition() = default; | ||
StopCondition(std::string text, | ||
lldb::LanguageType language = lldb::eLanguageTypeUnknown) | ||
: m_language(language) { | ||
SetText(std::move(text)); | ||
} | ||
|
||
explicit operator bool() const { return !m_text.empty(); } | ||
|
||
llvm::StringRef GetText() const { return m_text; } | ||
|
||
void SetText(std::string text) { | ||
static std::hash<std::string> hasher; | ||
m_text = std::move(text); | ||
m_hash = hasher(text); | ||
} | ||
|
||
size_t GetHash() const { return m_hash; } | ||
|
||
lldb::LanguageType GetLanguage() const { return m_language; } | ||
|
||
void SetLanguage(lldb::LanguageType language) { m_language = language; } | ||
|
||
private: | ||
/// The condition to test. | ||
std::string m_text; | ||
|
||
/// Its hash, so that locations know when the condition is updated. | ||
size_t m_hash = 0; | ||
|
||
/// The language for this condition. | ||
lldb::LanguageType m_language = lldb::eLanguageTypeUnknown; | ||
}; | ||
|
||
} // namespace lldb_private | ||
|
||
#endif // LLDB_BREAKPOINT_STOPCONDITION_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,7 +160,7 @@ void SBBreakpointLocation::SetCondition(const char *condition) { | |
if (loc_sp) { | ||
std::lock_guard<std::recursive_mutex> guard( | ||
loc_sp->GetTarget().GetAPIMutex()); | ||
loc_sp->SetCondition(condition); | ||
loc_sp->SetCondition(StopCondition(condition)); | ||
} | ||
} | ||
|
||
|
@@ -173,7 +173,7 @@ const char *SBBreakpointLocation::GetCondition() { | |
|
||
std::lock_guard<std::recursive_mutex> guard( | ||
loc_sp->GetTarget().GetAPIMutex()); | ||
return ConstString(loc_sp->GetConditionText()).GetCString(); | ||
return ConstString(loc_sp->GetCondition().GetText()).GetCString(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this code was like this before but why do we construct an intermediate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use |
||
} | ||
|
||
void SBBreakpointLocation::SetAutoContinue(bool auto_continue) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You removed the word "expression" from the help in Breakpoint.h, it's confusing to have these two differ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dropped it because the condition is more than just the expression text. Removed it here too for consistency. In all the user-facing strings we just use "breakpoint condition".