I am trying to understand Quantlib's finite-difference pricer using Eclipse with GDB debugger.

The code shown below prices an American put option using the Crank-Nicholson finite-difference scheme.

  1. I inserted a breakpoint on the line americanOption.NPV(); and attempted to step inside the associated function call, but found that the debugger simply steps over to the next line. Why is that?

  2. I was eventually able to catch a breakpoint in void TridiagonalOperator::solveFor(const Array& rhs, Array& result) const located in tridiagonaloperator.cpp. When I investigate the call stack, however, I get an incomprehensible list of function calls (screenshot: https://www.dropbox.com/s/bid7gae87zzx7tv/Screenshot%202015-12-05%2017.33.48.png?dl=0). How can I interpret this?

Can anyone suggest any strategies to more efficiently debug Quantlib?

#include <ql/quantlib.hpp>
using namespace QuantLib;

int main()
    Calendar calendar = UnitedStates();
    DayCounter dayCounter = Business252();
    Date t(1, Jan, 2014);
    Settings::instance().evaluationDate() = t;
    Date T(31, Dec, 2016);
    Option::Type type(Option::Put);
    Real S0 = 100;
    Real K = 100;
    Real delta = 0.00;
    Real r = 0.01;
    Real sigma = 0.2;

    Handle<Quote> underlying(
    Handle<YieldTermStructure> TS(
            boost::shared_ptr<YieldTermStructure>(boost::make_shared<FlatForward>(t, r, dayCounter)));
    Handle<YieldTermStructure> dividendTS(
            boost::shared_ptr<YieldTermStructure>(boost::make_shared<FlatForward>(t, delta, dayCounter)));
    Handle<BlackVolTermStructure> volTS(
            boost::shared_ptr<BlackVolTermStructure>(boost::make_shared<BlackConstantVol>(t, calendar, sigma, dayCounter)));
    boost::shared_ptr<BlackScholesMertonProcess> bsmProcess(
            boost::make_shared<BlackScholesMertonProcess>(underlying, dividendTS,TS, volTS));
    boost::shared_ptr<Exercise> americanExercise(
    boost::shared_ptr<StrikedTypePayoff> payoff(
            boost::make_shared<PlainVanillaPayoff>(type, K));
    VanillaOption americanOption(payoff, americanExercise);
    int timeSteps = 100;
    int gridPoints = 100;
    boost::shared_ptr<PricingEngine> engineFD(
            boost::make_shared<FDAmericanEngine<CrankNicolson>>(bsmProcess, timeSteps,gridPoints));
    std::cout << "PV = " << americanOption.NPV() << std::endl;    

1 Answer 1


Without a lot more information, it's difficult to say. Some explanations include (but are not limited to):

  • debugging symbols are not present; your system might be missing the libquant-dbg (or similar) package. If you compile your own libquant, enable debugging symbols by adding -g to your CFLAGS.

  • Eclipse is not configured correctly; this is a rather large rabbit hole, but if you're absolutely sure that debugging symbols are present, then you might be forced to troubleshoot the IDE. Sometimes an IDE will need to be told explicitly where to find headers and libraries.

Try compiling quantlib from source with CFLAGS=-g and directly invoke gdb on one of the example executables.


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.