8
contract users{
struct User{
    uint id;
    string str;
}
User [] public adds;
function del(){
    delete adds;
}
function delElem(uint i){
    delete adds[i];
}
function add(uint id,string cc){
    adds.push(User(id,cc));
}
function getLength()constant returns(uint){
    return adds.length;
}}

how to debug this contract in enter link description here, can breakpoint be valid?

1

1 Answer 1

5

There is no Solidity debugger, only an EVM debugger. That is one of the tabs on the right. It allows you to step through the EVM instructions and see the state of memory and storage. To debug solidity code, I suggest you add events instead. For example:

contract users{   
event LogThis(uint arg);
struct User{
    uint id;
    string str;
}
User [] public adds;
function del(){
    delete adds;
}
function delElem(uint i){
    delete adds[i];
}
function add(uint id,string cc){
    adds.push(User(id,cc));
}
function getLength()constant returns(uint){
    LogThis(adds.length);
    return adds.length;
}}

You will see this event when executing transactions.

1
  • 3
    Note that no event will execute if there is any throw in the chain of execution. So events are "fair weather friends". Commented Sep 4, 2016 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.