Announcement

Collapse
No announcement yet.

The State Of GNU's GDB Conversion To C++

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • The State Of GNU's GDB Conversion To C++

    Phoronix: The State Of GNU's GDB Conversion To C++

    Last year the GNU Debugger's code-base was converted from the C programming language (C90) to now using C++11. At last month's GNU Tools Cauldron was an update on this process...

    http://www.phoronix.com/scan.php?pag...onversion-2017

  • #2
    Garbage. Part of the rationale:

    The goal for moving to C++ is to make GDB more robust, easier to maintain, and to lower barriers for newcomers.
    • The C subset of C++ is just as efficient as C.
    Wow, great reasons guys. Hey, you should just skip the problems and convert to Swift. It's low-barrier and newcomers love it.

    Comment


    • #3
      Slightly over my head, but this means that GDB will be able to debug both C++ and C instead of just C?

      Comment


      • #4
        Originally posted by xeekei View Post
        Slightly over my head, but this means that GDB will be able to debug both C++ and C instead of just C?
        GDB is already able to debug many more languages than just C++ and C. As a general rule, you can implement a given functionality using any language, which has at least a few basic features like loops and branches and imposes no limit on the amount of memory you use, as long as your toolchain supports the right target.

        This conversion to C++ allows them to implement functions in more readable and maintainable ways, use some powerful C++-features that make it much easier to avoid certain mistakes and benefit from the fact that C++ is more suited for the programming paradigm they were already using anyway.

        Comment


        • #5
          i wish all pure c projects followed the same way, even for using only the c subset of c++ plus some zero performance overhead features as foreach...

          Comment


          • #6
            Originally posted by davidbepo View Post
            i wish all pure c projects followed the same way, even for using only the c subset of c++ plus some zero performance overhead features as foreach...
            Almost all of C++ is zero overhead. Just avoid exceptions and don't use virtual functions except to replace C jump tables.

            Gcc started by compiled their C code with C++ because it gave better errors and type checking, and then added some templated data-structures with overloads, that enforced correct usage in a few places they often made mistakes in C.

            Edit: foreach is a bad example though, it needs stl or stl-like containers, so it would not be easy to use for a C project, especially if they want to avoid all the STL stuff, and just want some better language features.
            Last edited by carewolf; 10-10-2017, 06:24 AM.

            Comment


            • #7
              Originally posted by carewolf View Post

              Almost all of C++ is zero overhead. Just avoid exceptions and don't use virtual functions except to replace C jump tables.

              Gcc started by compiled their C code with C++ because it gave better errors and type checking, and then added some templated data-structures with overloads, that enforced correct usage in a few places they often made mistakes in C.

              Edit: foreach is a bad example though, it needs stl or stl-like containers, so it would not be easy to use for a C project, especially if they want to avoid all the STL stuff, and just want some better language features.
              The only thing thats overhead in C++ are virtual functions and thats a feature you can choose to use or not. except its not really overhead since doing something similar in c is just about the same "overhead".

              Comment


              • #8
                Originally posted by carewolf View Post
                Edit: foreach is a bad example though, it needs stl or stl-like containers, so it would not be easy to use for a C project, especially if they want to avoid all the STL stuff, and just want some better language features.
                Well range-based for works with array as well. However, it does not work with dynamic array (new []), as the compiler can't determine the size of that array. It's possible to supply non-member begin()/end() to satisfy the syntax, but perhaps using plain old for loop might be easier.

                Comment


                • #9
                  Originally posted by carewolf View Post

                  Almost all of C++ is zero overhead. Just avoid exceptions and don't use virtual functions except to replace C jump tables.

                  Gcc started by compiled their C code with C++ because it gave better errors and type checking, and then added some templated data-structures with overloads, that enforced correct usage in a few places they often made mistakes in C.

                  Edit: foreach is a bad example though, it needs stl or stl-like containers, so it would not be easy to use for a C project, especially if they want to avoid all the STL stuff, and just want some better language features.
                  i was speaking about range based for (for(int num : sequence)), sorry for the confusion

                  Comment


                  • #10
                    Originally posted by cj.wijtmans View Post

                    The only thing thats overhead in C++ are virtual functions and thats a feature you can choose to use or not. except its not really overhead since doing something similar in c is just about the same "overhead".
                    Exceptions introduce their own overhead in setting up the catch frame. Using RTTI (features like dynamic_cast) also adds overhead. Both can be turned off though, and there are c++ projects which don't use them. virtual functions certainly beat the C approach of 'struct of function pointers'.

                    Comment

                    Working...
                    X