Skip to content

Commit 1203543

Browse files
committed
Ethdebug requires assembly instance
1 parent ef3311a commit 1203543

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

libevmasm/Ethdebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Json programInstructions(Assembly const& _assembly, LinkerObject const& _linkerO
7777

7878
} // anonymous namespace
7979

80-
Json ethdebug::program(std::string_view _name, unsigned _sourceId, Assembly const* _assembly, LinkerObject const& _linkerObject)
80+
Json ethdebug::program(std::string_view _name, unsigned _sourceId, Assembly const& _assembly, LinkerObject const& _linkerObject)
8181
{
8282
Json result = Json::object();
8383
result["contract"] = Json::object();

libevmasm/Ethdebug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace solidity::evmasm::ethdebug
2727
{
2828

2929
// returns ethdebug/format/program.
30-
Json program(std::string_view _name, unsigned _sourceId, Assembly const* _assembly, LinkerObject const& _linkerObject);
30+
Json program(std::string_view _name, unsigned _sourceId, Assembly const& _assembly, LinkerObject const& _linkerObject);
3131

3232
// returns ethdebug/format/info/resources
3333
Json resources(std::vector<std::string> const& _sources, std::string const& _version);

libsolidity/interface/CompilerStack.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,8 +1216,11 @@ Json CompilerStack::ethdebug(Contract const& _contract, bool _runtime) const
12161216
solUnimplementedAssert(!isExperimentalSolidity());
12171217
evmasm::LinkerObject const& object = _runtime ? _contract.runtimeObject : _contract.object;
12181218
std::shared_ptr<evmasm::Assembly> const& assembly = _runtime ? _contract.evmRuntimeAssembly : _contract.evmAssembly;
1219+
if (!assembly)
1220+
return {};
1221+
12191222
solAssert(sourceIndices().contains(_contract.contract->sourceUnitName()));
1220-
return evmasm::ethdebug::program(_contract.contract->name(), sourceIndices()[_contract.contract->sourceUnitName()], assembly.get(), object);
1223+
return evmasm::ethdebug::program(_contract.contract->name(), sourceIndices()[_contract.contract->sourceUnitName()], *assembly, object);
12211224
}
12221225

12231226
bytes CompilerStack::cborMetadata(std::string const& _contractName, bool _forIR) const

libyul/YulStack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,14 @@ YulStack::assembleWithDeployed(std::optional<std::string_view> _deployName)
275275
);
276276
}
277277
if (debugInfoSelection().ethdebug)
278-
creationObject.ethdebug = evmasm::ethdebug::program(creationObject.assembly->name(), 0, creationObject.assembly.get(), *creationObject.bytecode.get());
278+
creationObject.ethdebug = evmasm::ethdebug::program(creationObject.assembly->name(), 0, *creationObject.assembly, *creationObject.bytecode);
279279

280280
if (deployedAssembly)
281281
{
282282
deployedObject.bytecode = std::make_shared<evmasm::LinkerObject>(deployedAssembly->assemble());
283283
deployedObject.assembly = deployedAssembly;
284284
if (debugInfoSelection().ethdebug)
285-
deployedObject.ethdebug = evmasm::ethdebug::program(deployedObject.assembly->name(), 0, deployedObject.assembly.get(), *deployedObject.bytecode.get());
285+
deployedObject.ethdebug = evmasm::ethdebug::program(deployedObject.assembly->name(), 0, *deployedObject.assembly, *deployedObject.bytecode);
286286
solAssert(deployedAssembly->codeSections().size() == 1);
287287
deployedObject.sourceMappings = std::make_unique<std::string>(
288288
evmasm::AssemblyItem::computeSourceMapping(

test/libevmasm/Assembler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ BOOST_AUTO_TEST_CASE(ethdebug_program_last_instruction_with_immediate_arguments)
434434
assembly.append(AssemblyItem{0x11223344});
435435
LinkerObject output = assembly.assemble();
436436

437-
Json const program = ethdebug::program("", 0, &assembly, output);
437+
Json const program = ethdebug::program("", 0, assembly, output);
438438
BOOST_REQUIRE(program["instructions"].size() == 1);
439439
BOOST_REQUIRE(program["instructions"][0]["operation"]["mnemonic"] == "PUSH4");
440440
BOOST_REQUIRE(program["instructions"][0]["operation"]["arguments"][0] == "0x11223344");
@@ -445,7 +445,7 @@ BOOST_AUTO_TEST_CASE(ethdebug_program_last_instruction_with_immediate_arguments)
445445
assembly.append(AssemblyItem{0x1122334455});
446446
LinkerObject output = assembly.assemble();
447447

448-
Json const program = ethdebug::program("", 0, &assembly, output);
448+
Json const program = ethdebug::program("", 0, assembly, output);
449449
BOOST_REQUIRE(program["instructions"].size() == 2);
450450
BOOST_REQUIRE(program["instructions"][0]["operation"]["mnemonic"] == "PUSH0");
451451
BOOST_REQUIRE(!program["instructions"][0]["operation"].contains("arguments"));

0 commit comments

Comments
 (0)