I can't set breakpoints at function with input variables

Maniac

Apolyton Sage
Joined
Nov 27, 2004
Messages
5,588
Location
Gent, Belgium
I don't know if "input variables" is what you guys call it. I mean ::function(bool X, int Y,...) instead of ::function(void).

Is this normal? Or am I doing something wrong? How can I set breakpoints at such functions? It can sometimes be very hard to find a function(void) to set a breakpoint at to get to the function you really want to be in.
 
It would help if you show us precisely where in the code you attempted to place the breakpoint on screen for the screenshot as well. There are some places where the code doesn't ever actually hit, but the chances you clicked on one of those are slim. And normally it automatically relocates your breakpoint to the next valid location anyway.

There is not a restriction on being unable to break during certain functions though.

Did you try to put it on the very same line that says CvTeam::setHasTech(...)? That would be one of those places which isn't TECHNICALLY ever hit, you want to place the breakpoint somewhere inside of the function, like on the first { for instance.
 
In VS I am able to set breakpoints all over the place by clicking in the left margin--even on the blank line between two functions. Very strange. :confused:
 
Thanks, it works by clicking the left margin of the { sign. Unfortunately though then the name of the breakpoint is just 'CvTeam.cpp line 5369' or so instead of a function name.

For the record, I did it before by using the Breakpoint->New dropdown menu.
 
What does it matter if it breaks on the function name or the opening brace? Neither of those have executable code and so the break will really happen on the first executable line. I think I'm missing something in your question.

In this code, the first three lines don't do anything (unless x gets initialized to 0 by the compiler). If you break on this function, the program will stop on the "y = 2" assignment.

Code:
int foo(int bar)
{
    int x;
    int y = 2;    // first executable line

    x = 3;
    return x + y + bar;
}
 
Not in my experience with VS and Civ. If I place the break on the { then it breaks upon entering the function, the only variables that exist are those contained in "this" and bar. x and y won't exist until I let it advance another 2 or 3 lines.
 
What does it matter if it breaks on the function name or the opening brace? Neither of those have executable code and so the break will really happen on the first executable line. I think I'm missing something in your question.

What question are you refering to? :confused:
 
What question are you refering to? :confused:

I mean ::function(bool X, int Y,...) instead of ::function(void). . . . How can I set breakpoints at such functions?

I assume that you are clicking in the margin next to the function definition (the return type, name, and parameters). Are you saying that an orange dot doesn't appear next to it?
 
Not in my experience with VS and Civ. If I place the break on the { then it breaks upon entering the function, the only variables that exist are those contained in "this" and bar. x and y won't exist until I let it advance another 2 or 3 lines.

That tells me that the compiler is creating code that initializes those variables, though of course VS could just be "stepping" through non-existent code. The times I've used a visual debugger in the past (C, C++ and Java), it would only step through the lines that produced executable code. In Java variables must be manually initialized before use, but I don't recall how it would show you that in the debugger.

In the end, this is moot. The real question as I understand it is how to have it break on a function that takes parameters versus one that does not. AFAIK there should be no difference to the debugger. The only case I could see as being tricky is if the function is inlined, but I think all the inline functions are in the header files.
 
I assume that you are clicking in the margin next to the function definition (the return type, name, and parameters). Are you saying that an orange dot doesn't appear next to it?

I had never tried using the margin clicking method (which works, though then the breakpoint is called after a line instead of the function's name) before, before you suggested it in this thread. I used the Breakpoints->New->... menu instead where I copy-pasted the function name where I wanted a breakpoint.
 
Top Bottom