Skip to content

Commit

Permalink
Added explicit location #38
Browse files Browse the repository at this point in the history
  • Loading branch information
pirpyn committed Oct 16, 2023
1 parent c6a0983 commit 0a645e4
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 15 deletions.
65 changes: 51 additions & 14 deletions syntaxes/gdb.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"match": "\\b(-fu(?:nction)?)\\b[ \t]+([^[ \t]]+)",
"captures": {
"1": { "name": "support.function.option.gdb" },
"2": { "name": "markup.underline.link.location.gdb" }
"2": { "patterns": [ { "include": "#location"} ] }
}
},
{
Expand All @@ -80,7 +80,7 @@
"match": "\\b(fu(?:n(?:c(?:t(?:i(?:on?)?)?)?)?)?)\\b(?:[ \t]+([^[ \t]]+))?",
"captures": {
"1": { "name": "keyword.control.command.gdb" },
"2": { "name": "markup.underline.link.location.gdb" }
"2": { "patterns": [ { "include": "#location"} ] }
}
},
{
Expand Down Expand Up @@ -165,13 +165,14 @@
},
{
"name": "meta.command.break.gdb",
"match": "(?:^|\\G)[ \t]*(t?b(?:r(?:e(?:ak?)?)?)?)\\b(?:[ \t]+([^[ \t]]+)([ \t]+-force-condition)?(?:[ \t]+(if)[ \t]+(.*))?)?[ \t]*$",
"captures": {
"1": { "name": "keyword.control.command.gdb" },
"2": { "name": "markup.underline.link.location.gdb" },
"3": { "name": "support.function.option.gdb" },
"4": { "name": "keyword.control.condition.gdb" },
"5": { "patterns": [ { "include": "#expression" } ] }
"begin": "(?:^|\\G)[ \t]*(t?b(?:r(?:e(?:ak?)?)?)?)\\b",
"beginCaptures": { "1": { "name": "keyword.control.command.gdb" } },
"patterns": [ { "include": "#location"} ],
"end": "(?:([ \t]+-force-condition)?[ \t]+(if)[ \t]+(.+))?[ \t]*$",
"endCaptures": {
"1": { "name": "support.function.option.gdb" },
"2": { "name": "keyword.control.condition.gdb" },
"3": { "patterns": [ { "include": "#expression" } ] }
}
},
{
Expand Down Expand Up @@ -292,7 +293,7 @@
"match": "(?:^|\\G)[ \t]*(u(?:nt(?:il?)?)?)\\b(?:[ \t]+([^ \t]+))?[ \t]*$",
"captures": {
"1": { "name": "keyword.control.command.gdb" },
"2": { "name": "markup.underline.link.location.gdb" }
"2": { "patterns": [ { "include": "#location"} ] }
}
},
{
Expand Down Expand Up @@ -1030,7 +1031,7 @@
"match": "\\b(sc(?:o(?:pe?)?)?)\\b[ \t]+([^ \t]+)$",
"captures": {
"1": { "name": "support.function.option.gdb" },
"2": { "name": "markup.underline.link.location.gdb" }
"2": { "patterns": [ { "include": "#location"} ] }
}
},
{
Expand Down Expand Up @@ -1158,22 +1159,22 @@
"match": "\\b(t(?:r(?:a(?:c(?:e(?:p(?:o(?:i(?:n(?:ts?)?)?)?)?)?)?)?)?)?)\\b[ \t]+([^ \t]+)[ \t]*$",
"captures": {
"1": { "name": "support.function.option.gdb" },
"2": { "name": "markup.underline.link.location.gdb" }
"2": { "patterns": [ { "include": "#location"} ] }
}
},
{
"match": "\\b(b(?:r(?:e(?:a(?:k(?:p(?:o(?:i(?:n(?:ts?)?)?)?)?)?)?)?)?)?)\\b[ \t]+([^ \t]+)[ \t]*$",
"captures": {
"1": { "name": "support.function.option.gdb" },
"2": { "name": "markup.underline.link.location.gdb" }
"2": { "patterns": [ { "include": "#location"} ] }
}
},
{
"match": "\\b(g(?:d(?:b(?:-(?:i(?:n(?:d(?:ex?)?)?)?)?)?)?)?)(?:[ \t]+(-dwarf-5))?[ \t]+([^ \t]+)[ \t]*$",
"captures": {
"1": { "name": "support.function.option.gdb" },
"2": { "name": "support.function.sub-option.gdb" },
"3": { "name": "markup.underline.link.location.gdb" }
"3": { "patterns": [ { "include": "#location"} ] }
}
}
],
Expand Down Expand Up @@ -1415,6 +1416,42 @@
"end":"$"
}
]
},
"location": {
"patterns": [
{
"name": "meta.location.explicit.gdb",
"comment": "https://sourceware.org/gdb/current/onlinedocs/gdb.html/Explicit-Locations.html",
"patterns": [
{
"match": "\\B(-s(?:o(?:u(?:r(?:ce?)?)?)?)?)\\b",
"captures": { "1": { "name": "support.function.option.gdb" } }
},
{
"match": "\\B(-f(?:u(?:n(?:c(?:t(?:i(?:on?)?)?)?)?)?)?)\\b",
"captures": { "1": { "name": "support.function.option.gdb" } }
},
{
"match": "\\B(-li(?:ne?)?)\\b",
"captures": { "1": { "name": "support.function.option.gdb" } }
},
{
"match": "\\B(-la(?:b(?:el?)?)?)\\b",
"captures": { "1": { "name": "support.function.option.gdb" } }
},
{
"match": "\\B(-q(?:u(?:a(?:l(?:i(?:f(?:i(?:ed?)?)?)?)?)?)?)?)\\b",
"captures": { "1": { "name": "support.function.option.gdb" } }
}
]
},
{
"name": "meta.location.linespec.gdb",
"comment": "https://sourceware.org/gdb/current/onlinedocs/gdb.html/Linespec-Locations.html",
"match": "\\b([^ \t]+)\\b",
"captures": { "1": { "name": "markup.underline.link.location.gdb" } }
}
]
}
}
}
8 changes: 7 additions & 1 deletion tests/command/break.gdb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ b
br location_to_break
br location_to_break:1234
br location_to_break:1234 if expression
break 123 -force-condition if something
break 123 -force-condition if expression

break -qualified -function main
break -source foo/bar/snamestr.c
break -label ENDOF
break -line 12 -qualified 0x123
break -source foo/bar/snamestr.c -qualified -function main -line 12
8 changes: 8 additions & 0 deletions tests/command/break/function.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
break -f main
break -fu main
break -fun main
break -func main
break -funct main
break -functi main
break -functio main
break -function main
4 changes: 4 additions & 0 deletions tests/command/break/label.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
break -la LABEL
break -lab LABEL
break -labe LABEL
break -label LABEL
3 changes: 3 additions & 0 deletions tests/command/break/line.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
break -li 3
break -lin 3
break -line 3
9 changes: 9 additions & 0 deletions tests/command/break/qualified.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
break -q
break -qu
break -qua
break -qual
break -quali
break -qualif
break -qualifi
break -qualifie
break -qualified
6 changes: 6 additions & 0 deletions tests/command/break/source.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
break -s foo.c
break -so foo.c
break -sou foo.c
break -sour foo.c
break -sourc foo.c
break -source foo.c

2 comments on commit 0a645e4

@GitMensch
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure that those abbreviated versions work? [didn't checked, but the check for force-condition showed that this one cannot be abbreviated.]

@pirpyn
Copy link
Owner Author

@pirpyn pirpyn commented on 0a645e4 Oct 16, 2023

Choose a reason for hiding this comment

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

Explicit location options may be abbreviated by omitting any non-unique trailing characters from the option name, e.g., break -s main.c -li 3.

Please sign in to comment.