Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

gdb get return value of function

int fun() {
	return 42;
}

int main() {
	fun();
    return 0;
}

(gdb) break 2   // set breakpoint at line 2
(gdb) r

Breakpoint 1, fun () at test.c:2
2               return 42;

(gdb) finish   // $1 is the value the function returned.

Run till exit from #0  fun () at test.c:2
main () at test.c:7
7               return 0;
Value returned is $1 = 42   // we get the return value is 42
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #gdb #return #function
ADD COMMENT
Topic
Name
2+5 =