gdb: make a breakpoint on a class function in c++What are the differences between a pointer variable and a reference variable in C++?How can I profile C++ code running on Linux?The Definitive C++ Book Guide and ListWhat is the “-->” operator in C++?Why do we need virtual functions in C++?How to make a GDB breakpoint only break after the point is reached a given number times?Why is reading lines from stdin much slower in C++ than Python?setting a breakpoint in a specific line inside a function with 'gdb'C++ GDB breakpoint for member functionsWhat is the gdb command for setting a breakpoint with gdb?

Can fluent English speakers distinguish “steel”, “still” and “steal”?

Why was hardware diversification an asset for the IBM PC ecosystem?

What do the horizontal lines in a P-V phase diagram mean?

Is there a word for a message that is intended to be intercepted by an adversary?

Managing and organizing the massively increased number of classes after switching to SOLID?

Leave PhD after one year or finish it to the end?

How do Windows version numbers work?

Print the last, middle and first character of your code

Flatten array with OPENJSON: OPENJSON on a value that may not be an array? [ [1] ], vs [1]

Why does the autopilot disengage even when it does not receive pilot input?

Was lunar module "pilot" Harrison Schmitt legally a "pilot" at the time?

Are unclear "take-it or leave-it" contracts interpreted in my favor?

How can I get a player to accept that they should stop trying to pull stunts without thinking them through first?

Cops: The Hidden OEIS Substring

Why do players in the past play much longer tournaments than today's top players?

Would dual wielding daggers be a viable choice for a covert bodyguard?

How might the United Kingdom become a republic?

Can I play a first turn Simic Growth Chamber to have 3 mana available in the second turn?

will it increase or decrease my credit score, if i split a high balance on 2 credit cards

SOLVED - GFCI - should my neutral and ground have continuity?

Does throwing a penny at a train stop the train?

<schwitz>, <zwinker> etc. Does German always use 2nd Person Singular Imperative verbs for emoticons? If so, why?

Referring to different instances of the same character in time travel

Why does Hellboy file down his horns?



gdb: make a breakpoint on a class function in c++


What are the differences between a pointer variable and a reference variable in C++?How can I profile C++ code running on Linux?The Definitive C++ Book Guide and ListWhat is the “-->” operator in C++?Why do we need virtual functions in C++?How to make a GDB breakpoint only break after the point is reached a given number times?Why is reading lines from stdin much slower in C++ than Python?setting a breakpoint in a specific line inside a function with 'gdb'C++ GDB breakpoint for member functionsWhat is the gdb command for setting a breakpoint with gdb?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Assume the following class:



class a 
public:
int getA(int a)
return 5;

int getA(int a, int b)
return 6;

;

int main()
a cA;
std::cout << cA.getA(5) << std::endl;

return 0;



in gdb, I can set a breakpoint on the getA function using:



b a::getA


But this only sets a b on the first function, how do I make a b on the second function (without using line number of course)










share|improve this question




























    1















    Assume the following class:



    class a 
    public:
    int getA(int a)
    return 5;

    int getA(int a, int b)
    return 6;

    ;

    int main()
    a cA;
    std::cout << cA.getA(5) << std::endl;

    return 0;



    in gdb, I can set a breakpoint on the getA function using:



    b a::getA


    But this only sets a b on the first function, how do I make a b on the second function (without using line number of course)










    share|improve this question
























      1












      1








      1








      Assume the following class:



      class a 
      public:
      int getA(int a)
      return 5;

      int getA(int a, int b)
      return 6;

      ;

      int main()
      a cA;
      std::cout << cA.getA(5) << std::endl;

      return 0;



      in gdb, I can set a breakpoint on the getA function using:



      b a::getA


      But this only sets a b on the first function, how do I make a b on the second function (without using line number of course)










      share|improve this question














      Assume the following class:



      class a 
      public:
      int getA(int a)
      return 5;

      int getA(int a, int b)
      return 6;

      ;

      int main()
      a cA;
      std::cout << cA.getA(5) << std::endl;

      return 0;



      in gdb, I can set a breakpoint on the getA function using:



      b a::getA


      But this only sets a b on the first function, how do I make a b on the second function (without using line number of course)







      c++ gdb






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 26 at 3:38









      JoeJoe

      82 bronze badges




      82 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          3














          Add one more line to your main():



          std::cout << cA.getA(2,3) << std::endl;


          Now, repeat your original experiment. Your results will be different, now:





          (gdb) b a::getA
          Breakpoint 1 at 0x40089d: a::getA. (2 locations)


          "2 locations" is gdb telling you that it now injected breakpoints for both overloaded functions. Stepping through the code will verify this.



          If a symbol resolved to multiply-overloaded functions, the b command sets a breakpoint at each one.



          But because the 2nd overloaded function was an inline function and it was never called in your original code, gcc didn't even compile it, and there was nothing for gdb to set a breakpoint at.






          share|improve this answer






























            0














            b a::getA(int,int) should do the trick. Even the one that's already working should be replaceable with b a::getA(int).



            Try it yourself here.






            share|improve this answer

























              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349507%2fgdb-make-a-breakpoint-on-a-class-function-in-c%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              3














              Add one more line to your main():



              std::cout << cA.getA(2,3) << std::endl;


              Now, repeat your original experiment. Your results will be different, now:





              (gdb) b a::getA
              Breakpoint 1 at 0x40089d: a::getA. (2 locations)


              "2 locations" is gdb telling you that it now injected breakpoints for both overloaded functions. Stepping through the code will verify this.



              If a symbol resolved to multiply-overloaded functions, the b command sets a breakpoint at each one.



              But because the 2nd overloaded function was an inline function and it was never called in your original code, gcc didn't even compile it, and there was nothing for gdb to set a breakpoint at.






              share|improve this answer



























                3














                Add one more line to your main():



                std::cout << cA.getA(2,3) << std::endl;


                Now, repeat your original experiment. Your results will be different, now:





                (gdb) b a::getA
                Breakpoint 1 at 0x40089d: a::getA. (2 locations)


                "2 locations" is gdb telling you that it now injected breakpoints for both overloaded functions. Stepping through the code will verify this.



                If a symbol resolved to multiply-overloaded functions, the b command sets a breakpoint at each one.



                But because the 2nd overloaded function was an inline function and it was never called in your original code, gcc didn't even compile it, and there was nothing for gdb to set a breakpoint at.






                share|improve this answer

























                  3












                  3








                  3







                  Add one more line to your main():



                  std::cout << cA.getA(2,3) << std::endl;


                  Now, repeat your original experiment. Your results will be different, now:





                  (gdb) b a::getA
                  Breakpoint 1 at 0x40089d: a::getA. (2 locations)


                  "2 locations" is gdb telling you that it now injected breakpoints for both overloaded functions. Stepping through the code will verify this.



                  If a symbol resolved to multiply-overloaded functions, the b command sets a breakpoint at each one.



                  But because the 2nd overloaded function was an inline function and it was never called in your original code, gcc didn't even compile it, and there was nothing for gdb to set a breakpoint at.






                  share|improve this answer













                  Add one more line to your main():



                  std::cout << cA.getA(2,3) << std::endl;


                  Now, repeat your original experiment. Your results will be different, now:





                  (gdb) b a::getA
                  Breakpoint 1 at 0x40089d: a::getA. (2 locations)


                  "2 locations" is gdb telling you that it now injected breakpoints for both overloaded functions. Stepping through the code will verify this.



                  If a symbol resolved to multiply-overloaded functions, the b command sets a breakpoint at each one.



                  But because the 2nd overloaded function was an inline function and it was never called in your original code, gcc didn't even compile it, and there was nothing for gdb to set a breakpoint at.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 26 at 3:48









                  Sam VarshavchikSam Varshavchik

                  65.2k5 gold badges39 silver badges84 bronze badges




                  65.2k5 gold badges39 silver badges84 bronze badges























                      0














                      b a::getA(int,int) should do the trick. Even the one that's already working should be replaceable with b a::getA(int).



                      Try it yourself here.






                      share|improve this answer



























                        0














                        b a::getA(int,int) should do the trick. Even the one that's already working should be replaceable with b a::getA(int).



                        Try it yourself here.






                        share|improve this answer

























                          0












                          0








                          0







                          b a::getA(int,int) should do the trick. Even the one that's already working should be replaceable with b a::getA(int).



                          Try it yourself here.






                          share|improve this answer













                          b a::getA(int,int) should do the trick. Even the one that's already working should be replaceable with b a::getA(int).



                          Try it yourself here.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 26 at 3:49









                          aepaep

                          6715 silver badges14 bronze badges




                          6715 silver badges14 bronze badges



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349507%2fgdb-make-a-breakpoint-on-a-class-function-in-c%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

                              밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

                              1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴