Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1339)

Unified Diff: src/pkg/runtime/sys_x86.c

Issue 49580044: code review 49580044: runtime: if traceback sees a breakpoint, don't change the PC (Closed)
Patch Set: diff -r 8a9da0007914 https://code.google.com/p/go Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/runtime/sys_x86.c
===================================================================
--- a/src/pkg/runtime/sys_x86.c
+++ b/src/pkg/runtime/sys_x86.c
@@ -27,7 +27,6 @@
runtime·rewindmorestack(Gobuf *gobuf)
{
byte *pc;
- Func *f;
pc = (byte*)gobuf->pc;
if(pc[0] == 0xe9) { // jmp 4-byte offset
@@ -38,12 +37,18 @@
gobuf->pc = gobuf->pc + 2 + *(int8*)(pc+1);
return;
}
- if(pc[0] == 0xcc) { // breakpoint inserted by gdb
- f = runtime·findfunc(gobuf->pc);
- if(f != nil) {
- gobuf->pc = f->entry;
- return;
- }
+ if(pc[0] == 0xcc) {
+ // This is a breakpoint inserted by gdb. We could use
+ // runtime·findfunc to find the function. But if we
+ // do that, then we will continue execution at the
+ // function entry point, and we will not hit the gdb
+ // breakpoint. So for this case we don't change
+ // gobuf->pc, so that when we return we will execute
+ // the jump instruction and carry on. This means that
+ // stack unwinding may not work entirely correctly
+ // (http://golang.org/issue/5723) but the user is
+ // running under gdb anyhow.
+ return;
}
runtime·printf("runtime: pc=%p %x %x %x %x %x\n", pc, pc[0], pc[1], pc[2], pc[3], pc[4]);
runtime·throw("runtime: misuse of rewindmorestack");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b