-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dexter] Change line label reference syntax to enable label-relative …
…offsets (1/2) This patch changes how line labels are resolved in order to enable label-relative offsets to be used in commands. This is a breaking change in dexter. Instead of using label references directly as argument values, labels will instead be referenced through a function `ref(str)`. // No way to use offsets currently. Currently: DexExpectWatchValue('x', '1', on_line='labled_line') Patched: DexExpectWatchValue('x', '1', on_line=ref('labled_line')) Patched: DexExpectWatchValue('x', '1', on_line=ref('labled_line') + 3) A dexter command is "parsed" by finding the whole command and sending it off to `eval`. This change adds a function called `ref` to the `eval` globals map that simply looks up the name and returns an int. If the line name hasn't been defined, or a name is defined more than once, an error is reported (see err_bad_label_ref.cpp and err_duplicate_label.cpp). Label offsets can be achieved by simply writing the desired expression. The rationale behind removing the existing label referencing mechanic is for consistency and to simplify the code required to make labels work. I've separated the update to llvm's dexter tests into another patch for ease of review here (D101148). Here is a small python script which can be used to update tests to use the new syntax: https://gist.github.com/OCHyams/8255efe7757cac266440ed2ba55f1442 If it helps anyone using dexter on downstream tests we can come up with a deprecation plan instead out outright removing the existing syntax. Reviewed By: jmorse Differential Revision: https://reviews.llvm.org/D101147
- Loading branch information
Showing
8 changed files
with
100 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
debuginfo-tests/dexter/feature_tests/subtools/test/err_bad_label_ref.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Purpose: | ||
// Check that referencing an undefined label gives a useful error message. | ||
// | ||
// RUN: not %dexter_regression_test -v -- %s | FileCheck %s --match-full-lines | ||
// | ||
// CHECK: parser error:{{.*}}err_bad_label_ref.cpp(14): Unresolved label: 'label_does_not_exist' | ||
// CHECK-NEXT: {{Dex}}ExpectWatchValue('result', '0', on_line=ref('label_does_not_exist')) | ||
|
||
int main() { | ||
int result = 0; | ||
return result; | ||
} | ||
|
||
// DexExpectWatchValue('result', '0', on_line=ref('label_does_not_exist')) |
12 changes: 12 additions & 0 deletions
12
debuginfo-tests/dexter/feature_tests/subtools/test/err_duplicate_label.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Purpose: | ||
// Check that defining duplicate labels gives a useful error message. | ||
// | ||
// RUN: not %dexter_regression_test -v -- %s | FileCheck %s --match-full-lines | ||
// | ||
// CHECK: parser error:{{.*}}err_duplicate_label.cpp(11): Found duplicate line label: 'oops' | ||
// CHECK-NEXT: {{Dex}}Label('oops') | ||
|
||
int main() { | ||
int result = 0; // DexLabel('oops') | ||
return result; // DexLabel('oops') | ||
} |
24 changes: 24 additions & 0 deletions
24
debuginfo-tests/dexter/feature_tests/subtools/test/label_offset.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Purpose: | ||
// Check that we can use label-relative line numbers. | ||
// | ||
// RUN: %dexter_regression_test -v -- %s | FileCheck %s | ||
// | ||
// CHECK: label_offset.cpp: (1.0000) | ||
|
||
int main() { // DexLabel('main') | ||
int var = 0; | ||
var = var; | ||
return 0; | ||
} | ||
|
||
/* | ||
DexExpectWatchValue('var', '0', from_line=ref('main')+2, to_line=ref('main')+3) | ||
DexExpectProgramState({ | ||
'frames': [ | ||
{ | ||
'location': { 'lineno': ref('main')+2 }, | ||
'watches': { 'var': '0' } | ||
} | ||
] | ||
}) | ||
*/ |