Skip to content

Commit 5ecce28

Browse files
committed
GT-2905_emteere Putting out correct constructor line-number for nop
sleigh compiler argument '-n'
1 parent 89a4496 commit 5ecce28

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Ghidra/Framework/SoftwareModeling/src/main/antlr/ghidra/sleigh/grammar/SleighCompiler.g

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ macrodef
563563
}
564564
: ^(t=OP_MACRO n=unbound_identifier["macro"] a=arguments {
565565
symbol = sc.createMacro(find(n), n.getText(), a.first, a.second);
566-
} s=semantic[env, sc.pcode, $t, false, true]) {
566+
} s=semantic[env, null, sc.pcode, $t, false, true]) {
567567
if (symbol != null) {
568568
sc.buildMacro(symbol, $macrodef::macrobody);
569569
}
@@ -612,13 +612,13 @@ constructorlikelist
612612
;
613613

614614
constructor
615-
: ^(OP_CONSTRUCTOR c=ctorstart e=bitpattern b=contextblock r=ctorsemantic) {
615+
: ^(OP_CONSTRUCTOR c=ctorstart e=bitpattern b=contextblock r=ctorsemantic[c]) {
616616
sc.buildConstructor(c, e, b, r);
617617
}
618618
;
619619

620-
ctorsemantic returns [SectionVector value]
621-
: ^(t=OP_PCODE p=semantic[env, sc.pcode, $t, true, false]) { $value = p; }
620+
ctorsemantic[Constructor ctor] returns [SectionVector value]
621+
: ^(t=OP_PCODE p=semantic[env, ctor.location, sc.pcode, $t, true, false]) { $value = p; }
622622
| ^(OP_PCODE OP_UNIMPL) { /*unimpl unimplemented ; */ $value = null; }
623623
;
624624

@@ -941,7 +941,7 @@ cstatement[VectorSTL<ContextChange> r]
941941
}
942942
;
943943

944-
semantic[ParsingEnvironment pe, PcodeCompile pcode, Tree where, boolean sectionsAllowed, boolean isMacroParse] returns [SectionVector rtl]
944+
semantic[ParsingEnvironment pe, Location containerLoc, PcodeCompile pcode, Tree where, boolean sectionsAllowed, boolean isMacroParse] returns [SectionVector rtl]
945945
scope {
946946
SectionVector sections;
947947
boolean containsMultipleSections;
@@ -966,7 +966,11 @@ semantic[ParsingEnvironment pe, PcodeCompile pcode, Tree where, boolean sections
966966
: ^(x=OP_SEMANTIC c=code_block[find($x)] {
967967
if (c != null) {
968968
if (c.getOpvec().empty() && c.getResult() == null) {
969-
pcode.recordNop(find(where));
969+
Location loc = find(where);
970+
if (loc == null) {
971+
loc = containerLoc;
972+
}
973+
pcode.recordNop(loc);
970974
}
971975
if ($semantic::containsMultipleSections) {
972976
$semantic::sections = pcode.finalNamedSection($semantic::sections, c);

Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/slgh_compile/PcodeParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public ConstructTpl compilePcode(String pcodeStatements, String srcFile, int src
312312
// ANTLRUtil.debugNodeStream(nodes, System.out);
313313
SleighCompiler walker = new SleighCompiler(nodes);
314314

315-
SectionVector rtl = walker.semantic(env, this, semantic.getTree(), false, false);
315+
SectionVector rtl = walker.semantic(env, null, this, semantic.getTree(), false, false);
316316

317317
if (getErrors() != 0) {
318318
return null;

0 commit comments

Comments
 (0)