Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any plans for C++14 or later for standardized backtrace and other debugging utilities?

Are there any plans for standardized backtrace and other debugging utilities to be added to C++14 (or above), or will it continue to be a functionality added by OS or compiler?

like image 325
DuckQueen Avatar asked Feb 17 '14 00:02

DuckQueen


3 Answers

No. There are no plans.

For one the standard does not specify how function calls are to be made. And in all actuality this is dependent upon the hardware. You probably dont know this but there is hardware out there that does not push return addresses onto a stack. Some of them use dynamic jmp instructions, and others use return queues to keep track of return addressees.

The stack trace which you're referring to is possible on a, albeit large, subset of processors, but since C and C++ was intended to run on as many processors as possible it will not, can not, define a standard way of performing a back trace which would dictate how hardware should be manufactured.

like image 156
Dan Avatar answered Oct 21 '22 02:10

Dan


As Dan said, no backtrace and no plan to do it, up to my knowledge. About debugging utilities, besides asserts I only know standard macros inherited from C, like

  • __FILE__ to know the name of the current input file,
  • __LINE__ to know the current input line number,
  • __func__ to know the current function.

For instance

    1. #include <iostream>
    2. 
    3. int main() {
    4.   std::cout << "File " << __FILE__ << ", line " << __LINE__ << std::endl;
    5. }

will output

    File /path/your_bin, line 4

More details here: http://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html

like image 27
Florian Richoux Avatar answered Oct 21 '22 03:10

Florian Richoux


You can get a pretty good overview of what is going into the next standard by looking at the documents published by the standards committee:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/

There you can find proposals written by various people, meeting minutes, draft standards, and issue lists.

Given the status of C++14, the draft standards is the most informative document for your particular question. Short answer: there's nothing new for debugging in there.

There was a paper about stack traces back in 2012:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3441.html

However, it doesn't seem to have left any traces in the actual standard. If you want to find out more, you could try reading the minutes of the meetings around there, or contact the paper's author - not everything is recorded in the meetings, just the sessions where everyone gets together and votes, but not the work of individual groups.

like image 1
Sebastian Redl Avatar answered Oct 21 '22 03:10

Sebastian Redl