From 192cbba9440ddf2171363ae74028d3f279c83b1c Mon Sep 17 00:00:00 2001 From: Jim Kingdon Date: Mon, 22 Apr 1991 21:40:42 +0000 Subject: [PATCH] * sparc-tdep.c (skip_prologue): Don't skip anything unless there is a "save" instruction in there somewhere. --- gdb/ChangeLog | 3 +++ gdb/sparc-tdep.c | 24 ++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b0358d8e8cf..595a6538617 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,8 @@ Mon Apr 22 00:02:43 1991 Jim Kingdon (kingdon at cygint.cygnus.com) + * sparc-tdep.c (skip_prologue): Don't skip anything unless there + is a "save" instruction in there somewhere. + * symfile.c (symbol_file_add): Add comment. solib.c (solib_add): Don't malloc name passed to symbol_file_add. diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index e0fb8ba79d4..29544972eac 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -268,13 +268,10 @@ do_restore_insn () } /* This routine should be more specific in it's actions; making sure - that it uses the same register in the initial prologue section. - Also, FIXME-SOON, it should recognize leaf functions as ones without - a SAVE in the prologue, and pass that info back to the caller so the - PC and arguments can be properly located. */ + that it uses the same register in the initial prologue section. */ CORE_ADDR -skip_prologue (pc) - CORE_ADDR pc; +skip_prologue (start_pc) + CORE_ADDR start_pc; { union { @@ -298,6 +295,9 @@ skip_prologue (pc) int i; } x; int dest = -1; + CORE_ADDR pc = start_pc; + /* Have we found a save instruction? */ + int found_save = 0; x.i = read_memory_integer (pc, 4); @@ -311,7 +311,10 @@ skip_prologue (pc) /* Recognize an add immediate value to register to either %g1 or the destination register recorded above. Actually, this might - well recognize several different arithmetic operations. */ + well recognize several different arithmetic operations. + It doesn't check that rs1 == rd because in theory "sub %g0, 5, %g1" + followed by "save %sp, %g1, %sp" is a valid prologue (Not that + I imagine any compiler really does that, however). */ if (x.add.op == 2 && x.add.i && (x.add.rd == 1 || x.add.rd == dest)) { pc += 4; @@ -323,6 +326,7 @@ skip_prologue (pc) as there isn't any sign extension). */ if (x.add.op == 2 && (x.add.op3 ^ 32) == 28) { + found_save = 1; pc += 4; x.i = read_memory_integer (pc, 4); } @@ -342,7 +346,11 @@ skip_prologue (pc) pc += 4; x.i = read_memory_integer (pc, 4); } - return pc; + if (found_save) + return pc; + else + /* Without a save instruction, it's not a prologue. */ + return start_pc; } /* Check instruction at ADDR to see if it is an annulled branch. -- 2.30.2