Skip to content

[LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… #95738

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions lldb/docs/dil-expr-lang.ebnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(* LLDB Debug Expressions, a subset of C++ *)
(* Insired by https://www.nongnu.org/hcb *)

expression = unary_expression;

unary_expression = postfix_expression
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to allow state-changing expressions in the frame var language?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is pretty useful to be able to easily change the program state and afaik it's already possible with expr command. Generally other debugger allow this as well (e.g. Visual Studio), so I think it's a reasonable thing to do. However, for increments specifically there's a deeper reason here (and I would agree that they probably shouldn't be available for general use). See my big comment below for justification.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to have a convenient way to change a variable value without invoking the full expression parser (or going into python), but I think there's a discussion to be made about how to expose that functionality. For example, the current envisioned entry points into this code (the "frame variable" CLI cmd, and SBFrame.GetValueForVariablePath don't exactly sound like they ought to be modifying the variable in the process of "getting" it).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, many users confuse or conflate "frame variable" with "p" (the short-cut for the expression evaluator), the "p" certainly allows updating the variable value...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be one way to resolve this -- have p/dwim-print activate some "extended" mode of DIL which allows for variable modification. But let's save that for later...

| unary_operator unary_expression;

unary_operator = "*" | "&" | "-" ;

postfix_expression = primary_expression
| postfix_expression "[" expression "]"
| postfix_expression "." id_expression
| postfix_expression "->" id_expression

primary_expression = numeric_literal
| boolean_literal
| pointer_literal
| id_expression;

nested_name_specifier = namespace_name '::'
| nested_name_specifier identifier "::";

namespace_name = identifier ;

id_expression = unqualified_id
| qualified_id ;

unqualified_id = identifier ;

qualified_id = [nested_name_specifier] unqualified_id
| identifier ;

identifier = ? clang::tok::identifier ? ;

numeric_literal = ? clang::tok::numeric_constant ? ;
Loading