Raiyan Kabir
Raiyan Kabir

Reputation: 1016

How to call a public function of a C++ object in lldb command line?

I'm trying to test the result of a C++ function call. The function is public and the debugger is inside a call where the object is a member. Here is the class interface:

class NumerialDispersion {
    MeshSystem mesh;

    vector<double> b_k;
    vector<double> c_k;


public:
    void setupMeshSystem();
    void setUpAnalysis();
    void calculateK();
};

I Need to test a function that I have declared inside MeshSystem. The interface of MeshSystem class is as follows:

class MeshSystem {

    Element mainMeshElement;


public:
    MeshSystem(Element element, double tStep);


    double get_b_k(uint index);

};

I need to execute the function get_b_k() in lldb with different values of index. I am using Xcode 4.6 user Mountain Lion.

Does lldb supports such expressions? If yes, could any one help me?

Many many thanks in advance.

Upvotes: 2

Views: 3042

Answers (1)

dev_null
dev_null

Reputation: 1997

either type

p mesh.get_b_k(1)

or

expr -- mesh.get_b_k(1)

Note that the function may be not present in a target at all, that is not used and its body just was not compiled. In this case use it in some fake way, or make exportable (annotate with attribute ((visibility ("default"))) )

Upvotes: 2

Related Questions