1
1
/*
2
- * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* The Universal Permissive License (UPL), Version 1.0
41
41
42
42
package org .graalvm .wasm .test .suites .debugging ;
43
43
44
- import com .oracle .truffle .api .source .Source ;
44
+ import java .nio .file .Path ;
45
+ import java .util .ArrayList ;
46
+
45
47
import org .graalvm .collections .EconomicMap ;
46
- import org .graalvm .wasm .WasmLanguage ;
47
48
import org .graalvm .wasm .collection .LongArrayList ;
48
49
import org .graalvm .wasm .debugging .DebugLineMap ;
49
50
import org .graalvm .wasm .debugging .data .DebugFunction ;
60
61
import org .junit .Assert ;
61
62
import org .junit .Test ;
62
63
63
- import java .nio .file .Path ;
64
- import java .util .ArrayList ;
65
-
66
64
/**
67
65
* Test suite for debug entries based on the specification in the
68
66
* <a href="https://dwarfstd.org/doc/DWARF4.pdf">DWARF Debug Information format</a>.
@@ -118,7 +116,7 @@ private static DebugParserContext parseCompilationUnit(TestObjectFactory factory
118
116
return parseCompilationUnit (factory , null , null , children );
119
117
}
120
118
121
- private static DebugParserContext parseCompilationUnit (TestObjectFactory factory , DebugLineMap lineMap , Source source , DebugData ... children ) {
119
+ private static DebugParserContext parseCompilationUnit (TestObjectFactory factory , DebugLineMap lineMap , Path path , DebugData ... children ) {
122
120
final byte [] data = {};
123
121
final DebugData compUnit = getCompilationUnit (children );
124
122
final DebugLineMap [] lineMaps ;
@@ -127,13 +125,13 @@ private static DebugParserContext parseCompilationUnit(TestObjectFactory factory
127
125
} else {
128
126
lineMaps = null ;
129
127
}
130
- final Source [] sources ;
131
- if (source != null ) {
132
- sources = new Source []{source };
128
+ final Path [] paths ;
129
+ if (path != null ) {
130
+ paths = new Path []{path };
133
131
} else {
134
- sources = null ;
132
+ paths = null ;
135
133
}
136
- final DebugParserContext context = new DebugParserContext (data , 0 , getEntryData (compUnit ), lineMaps , sources );
134
+ final DebugParserContext context = new DebugParserContext (data , 0 , getEntryData (compUnit ), lineMaps , paths , "wasm" , factory );
137
135
final DebugParserScope scope = DebugParserScope .createGlobalScope ();
138
136
for (DebugData d : compUnit .children ()) {
139
137
factory .parse (context , scope , d );
@@ -1073,29 +1071,29 @@ public void testEnumTypeMissingBaseType() {
1073
1071
1074
1072
@ Test
1075
1073
public void testFunction () {
1076
- final DebugLineMap lineMap = new DebugLineMap (Path .of ("" ));
1074
+ final Path p = Path .of ("" );
1075
+ final DebugLineMap lineMap = new DebugLineMap (p );
1077
1076
lineMap .add (0 , 1 );
1078
1077
lineMap .add (10 , 2 );
1079
- final Source s = Source .newBuilder (WasmLanguage .ID , "" , "test" ).internal (true ).build ();
1080
1078
final AttributeBuilder funcAttr = AttributeBuilder .create ().add (Attributes .DECL_FILE , 0x0F , 0 ).add (Attributes .NAME , 0x08 , "func" ).add (Attributes .LOW_PC , 0x0F , 0 ).add (Attributes .HIGH_PC , 0x0F ,
1081
1079
10 ).add (Attributes .FRAME_BASE , 0x09 , new byte []{});
1082
1080
final DebugData func = new DebugData (Tags .SUBPROGRAM , 1 , funcAttr .attributeInfo (), funcAttr .attributeValues (), new DebugData [0 ]);
1083
1081
1084
1082
final TestObjectFactory factory = new TestObjectFactory ();
1085
- final DebugParserContext context = parseCompilationUnit (factory , lineMap , s , func );
1083
+ final DebugParserContext context = parseCompilationUnit (factory , lineMap , p , func );
1086
1084
1087
1085
Assert .assertEquals (1 , context .functions ().size ());
1088
1086
}
1089
1087
1090
1088
@ Test
1091
1089
public void testFunctionMissingLineMap () {
1092
- final Source s = Source . newBuilder ( WasmLanguage . ID , "" , "test" ). internal ( true ). build ( );
1090
+ final Path p = Path . of ( "" );
1093
1091
final AttributeBuilder funcAttr = AttributeBuilder .create ().add (Attributes .DECL_FILE , 0x0F , 0 ).add (Attributes .NAME , 0x08 , "func" ).add (Attributes .LOW_PC , 0x0F , 0 ).add (Attributes .HIGH_PC , 0x0F ,
1094
1092
10 ).add (Attributes .FRAME_BASE , 0x09 , new byte []{});
1095
1093
final DebugData func = new DebugData (Tags .SUBPROGRAM , 1 , funcAttr .attributeInfo (), funcAttr .attributeValues (), new DebugData [0 ]);
1096
1094
1097
1095
final TestObjectFactory factory = new TestObjectFactory ();
1098
- final DebugParserContext context = parseCompilationUnit (factory , null , s , func );
1096
+ final DebugParserContext context = parseCompilationUnit (factory , null , p , func );
1099
1097
1100
1098
Assert .assertEquals (0 , context .functions ().size ());
1101
1099
}
@@ -1117,42 +1115,42 @@ public void testFunctionMissingSource() {
1117
1115
1118
1116
@ Test
1119
1117
public void testInlinedFunction () {
1120
- final DebugLineMap lineMap = new DebugLineMap (Path .of ("" ));
1118
+ final Path p = Path .of ("" );
1119
+ final DebugLineMap lineMap = new DebugLineMap (p );
1121
1120
lineMap .add (0 , 1 );
1122
1121
lineMap .add (10 , 2 );
1123
- final Source s = Source .newBuilder (WasmLanguage .ID , "" , "test" ).internal (true ).build ();
1124
1122
final AttributeBuilder funcAttr = AttributeBuilder .create ().add (Attributes .DECL_FILE , 0x0F , 0 ).add (Attributes .NAME , 0x08 , "func" ).add (Attributes .LOW_PC , 0x0F , 0 ).add (Attributes .HIGH_PC , 0x0F ,
1125
1123
10 ).add (Attributes .FRAME_BASE , 0x09 , new byte []{}).add (Attributes .INLINE , 0x0F , 1 );
1126
1124
final DebugData func = new DebugData (Tags .SUBPROGRAM , 1 , funcAttr .attributeInfo (), funcAttr .attributeValues (), new DebugData [0 ]);
1127
1125
1128
1126
final TestObjectFactory factory = new TestObjectFactory ();
1129
- final DebugParserContext context = parseCompilationUnit (factory , lineMap , s , func );
1127
+ final DebugParserContext context = parseCompilationUnit (factory , lineMap , p , func );
1130
1128
1131
1129
Assert .assertEquals (0 , context .functions ().size ());
1132
1130
}
1133
1131
1134
1132
@ Test
1135
1133
public void testFunctionMissingFrameBase () {
1136
- final DebugLineMap lineMap = new DebugLineMap (Path .of ("" ));
1134
+ final Path p = Path .of ("" );
1135
+ final DebugLineMap lineMap = new DebugLineMap (p );
1137
1136
lineMap .add (0 , 1 );
1138
1137
lineMap .add (10 , 2 );
1139
- final Source s = Source .newBuilder (WasmLanguage .ID , "" , "test" ).internal (true ).build ();
1140
1138
final AttributeBuilder funcAttr = AttributeBuilder .create ().add (Attributes .DECL_FILE , 0x0F , 0 ).add (Attributes .NAME , 0x08 , "func" ).add (Attributes .LOW_PC , 0x0F , 0 ).add (Attributes .HIGH_PC , 0x0F ,
1141
1139
10 );
1142
1140
final DebugData func = new DebugData (Tags .SUBPROGRAM , 1 , funcAttr .attributeInfo (), funcAttr .attributeValues (), new DebugData [0 ]);
1143
1141
1144
1142
final TestObjectFactory factory = new TestObjectFactory ();
1145
- final DebugParserContext context = parseCompilationUnit (factory , lineMap , s , func );
1143
+ final DebugParserContext context = parseCompilationUnit (factory , lineMap , p , func );
1146
1144
1147
1145
Assert .assertEquals (0 , context .functions ().size ());
1148
1146
}
1149
1147
1150
1148
@ Test
1151
1149
public void testFunctionWithVariables () {
1152
- final DebugLineMap lineMap = new DebugLineMap (Path .of ("" ));
1150
+ final Path p = Path .of ("" );
1151
+ final DebugLineMap lineMap = new DebugLineMap (p );
1153
1152
lineMap .add (0 , 1 );
1154
1153
lineMap .add (10 , 2 );
1155
- final Source s = Source .newBuilder (WasmLanguage .ID , "" , "test" ).internal (true ).build ();
1156
1154
1157
1155
final AttributeBuilder baseAttr = AttributeBuilder .create ().add (Attributes .NAME , 0x08 , "int" ).add (Attributes .ENCODING , 0x0F , AttributeEncodings .SIGNED ).add (Attributes .BYTE_SIZE , 0x0F , 4 );
1158
1156
final DebugData baseType = new DebugData (Tags .BASE_TYPE , 1 , baseAttr .attributeInfo (), baseAttr .attributeValues (), new DebugData [0 ]);
@@ -1172,7 +1170,7 @@ public void testFunctionWithVariables() {
1172
1170
final DebugData func = new DebugData (Tags .SUBPROGRAM , 3 , funcAttr .attributeInfo (), funcAttr .attributeValues (), new DebugData []{var1 , var2 , var3 });
1173
1171
1174
1172
final TestObjectFactory factory = new TestObjectFactory ();
1175
- final DebugParserContext context = parseCompilationUnit (factory , lineMap , s , baseType , func );
1173
+ final DebugParserContext context = parseCompilationUnit (factory , lineMap , p , baseType , func );
1176
1174
1177
1175
Assert .assertEquals (1 , context .functions ().size ());
1178
1176
final DebugFunction function = context .functions ().get (0 );
@@ -1181,10 +1179,10 @@ public void testFunctionWithVariables() {
1181
1179
1182
1180
@ Test
1183
1181
public void testFunctionWithVariableMissingTypeAttribute () {
1184
- final DebugLineMap lineMap = new DebugLineMap (Path .of ("" ));
1182
+ final Path p = Path .of ("" );
1183
+ final DebugLineMap lineMap = new DebugLineMap (p );
1185
1184
lineMap .add (0 , 1 );
1186
1185
lineMap .add (10 , 2 );
1187
- final Source s = Source .newBuilder (WasmLanguage .ID , "" , "test" ).internal (true ).build ();
1188
1186
1189
1187
final AttributeBuilder baseAttr = AttributeBuilder .create ().add (Attributes .NAME , 0x08 , "int" ).add (Attributes .ENCODING , 0x0F , AttributeEncodings .SIGNED ).add (Attributes .BYTE_SIZE , 0x0F , 4 );
1190
1188
final DebugData baseType = new DebugData (Tags .BASE_TYPE , 1 , baseAttr .attributeInfo (), baseAttr .attributeValues (), new DebugData [0 ]);
@@ -1198,7 +1196,7 @@ public void testFunctionWithVariableMissingTypeAttribute() {
1198
1196
final DebugData func = new DebugData (Tags .SUBPROGRAM , 3 , funcAttr .attributeInfo (), funcAttr .attributeValues (), new DebugData []{var });
1199
1197
1200
1198
final TestObjectFactory factory = new TestObjectFactory ();
1201
- final DebugParserContext context = parseCompilationUnit (factory , lineMap , s , baseType , func );
1199
+ final DebugParserContext context = parseCompilationUnit (factory , lineMap , p , baseType , func );
1202
1200
1203
1201
Assert .assertEquals (1 , context .functions ().size ());
1204
1202
final DebugFunction function = context .functions ().get (0 );
@@ -1207,10 +1205,10 @@ public void testFunctionWithVariableMissingTypeAttribute() {
1207
1205
1208
1206
@ Test
1209
1207
public void testFunctionWithVariableMissingType () {
1210
- final DebugLineMap lineMap = new DebugLineMap (Path .of ("" ));
1208
+ final Path p = Path .of ("" );
1209
+ final DebugLineMap lineMap = new DebugLineMap (p );
1211
1210
lineMap .add (0 , 1 );
1212
1211
lineMap .add (10 , 2 );
1213
- final Source s = Source .newBuilder (WasmLanguage .ID , "" , "test" ).internal (true ).build ();
1214
1212
1215
1213
final AttributeBuilder varAttr = AttributeBuilder .create ().add (Attributes .NAME , 0x08 , "c" ).add (Attributes .TYPE , 0x0F , 1 ).add (Attributes .LOCATION , 0x09 , new byte [0 ]).add (Attributes .DECL_FILE ,
1216
1214
0x0F , 0 ).add (Attributes .DECL_LINE , 0x0F , 1 );
@@ -1221,7 +1219,7 @@ public void testFunctionWithVariableMissingType() {
1221
1219
final DebugData func = new DebugData (Tags .SUBPROGRAM , 3 , funcAttr .attributeInfo (), funcAttr .attributeValues (), new DebugData []{var });
1222
1220
1223
1221
final TestObjectFactory factory = new TestObjectFactory ();
1224
- final DebugParserContext context = parseCompilationUnit (factory , lineMap , s , func );
1222
+ final DebugParserContext context = parseCompilationUnit (factory , lineMap , p , func );
1225
1223
1226
1224
Assert .assertEquals (1 , context .functions ().size ());
1227
1225
final DebugFunction function = context .functions ().get (0 );
0 commit comments