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;
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
add a comment |
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
add a comment |
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
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
c++ gdb
asked Mar 26 at 3:38
JoeJoe
82 bronze badges
82 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
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
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 26 at 3:49
aepaep
6715 silver badges14 bronze badges
6715 silver badges14 bronze badges
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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