Next: , Previous: , Up: C and C++   [Contents][Index]


15.4.1.3 C++ Expressions

ROCGDB expression handling can interpret most C++ expressions.

Warning: ROCGDB can only debug C++ code if you use the proper compiler and the proper debug format. Currently, ROCGDB works best when debugging C++ code that is compiled with the most recent version of GCC possible. The DWARF debugging format is preferred; GCC defaults to this on most popular platforms. Other compilers and/or debug formats are likely to work badly or not at all when using ROCGDB to debug C++ code. See Compiling for Debugging.

  1. Member function calls are allowed; you can use expressions like
    count = aml->GetOriginal(x, y)
    
  2. While a member function is active (in the selected stack frame), your expressions have the same namespace available as the member function; that is, ROCGDB allows implicit references to the class instance pointer this following the same rules as C++. using declarations in the current scope are also respected by ROCGDB.
  3. You can call overloaded functions; ROCGDB resolves the function call to the right definition, with some restrictions. ROCGDB does not perform overload resolution involving user-defined type conversions, calls to constructors, or instantiations of templates that do not exist in the program. It also cannot handle ellipsis argument lists or default arguments.

    It does perform integral conversions and promotions, floating-point promotions, arithmetic conversions, pointer conversions, conversions of class objects to base classes, and standard conversions such as those of functions or arrays to pointers; it requires an exact match on the number of function arguments.

    Overload resolution is always performed, unless you have specified set overload-resolution off. See ROCGDB Features for C++.

    You must specify set overload-resolution off in order to use an explicit function signature to call an overloaded function, as in

    p 'foo(char,int)'('x', 13)
    

    The ROCGDB command-completion facility can simplify this; see Command Completion.

  4. ROCGDB understands variables declared as C++ lvalue or rvalue references; you can use them in expressions just as you do in C++ source—they are automatically dereferenced.

    In the parameter list shown when ROCGDB displays a frame, the values of reference variables are not displayed (unlike other variables); this avoids clutter, since references are often used for large structures. The address of a reference variable is always shown, unless you have specified ‘set print address off’.

  5. ROCGDB supports the C++ name resolution operator ::—your expressions can use it just as expressions in your program do. Since one scope may be defined in another, you can use :: repeatedly if necessary, for example in an expression like ‘scope1::scope2::name’. ROCGDB also allows resolving name scope by reference to source files, in both C and C++ debugging (see Program Variables).
  6. ROCGDB performs argument-dependent lookup, following the C++ specification.

Next: C and C++ Defaults, Previous: C and C++ Constants, Up: C and C++   [Contents][Index]