7
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?

4

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.

  • 3
    Note that no event will execute if there is any throw in the chain of execution. So events are "fair weather friends". – Xavier Leprêtre B9lab Sep 4 '16 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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