From: "J. Johnston" <jjohnstn@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: RFC: patch to refresh prev_pc
Date: Mon, 05 May 2003 20:48:00 -0000 [thread overview]
Message-ID: <3EB6CE0A.4070409@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1489 bytes --]
The following patch solves a problem on the ia64. The problem
exists because of a generic problem to reset the prev_pc value
after an inferior function call or after a return command.
Because the value is not properly set, the line number used to
initialize the ecs is incorrect. On the ia64 this causes a problem
because there are extraneous linetable entries generated by the compiler
that are within the line (i.e. they don't change the line number).
When we apply "next" logic which uses the ecs line number, we end up stopping
at the first line table entry past our start position. This often ends
up being just a few insns farther in the same line. A specific example
of this problem is the next to 1237 test inside call-ar-st.exp. An
inferior call is made on line 1236 and upon return we issue a next.
I discussed this topic on the gdb forum and a number of attempts were
made to ensure the prev_pc value was up to date in init_execution_control_state()
in infrun.c. Those attempts failed because the inferior was not guaranteed to
be stopped and so we weren't guaranteed that a ptrace to fetch the pc would work.
This patch attempts to refresh the prev_pc value just before resuming in proceed().
It works for the ia64 problems cited above and also I have tested it on the x86.
Is this patch ok?
-- Jeff J.
2003-05-05 Jeff Johnston <jjohnstn@redhat.com>
* infrun.c (prev_pc): Move declaration ahead of proceed().
(proceed): Refresh prev_pc value before resuming.
[-- Attachment #2: prev_pc.patch --]
[-- Type: text/plain, Size: 1472 bytes --]
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.108
diff -u -p -r1.108 infrun.c
--- infrun.c 5 May 2003 00:27:07 -0000 1.108
+++ infrun.c 5 May 2003 20:34:16 -0000
@@ -667,6 +667,12 @@ clear_proceed_status (void)
bpstat_clear (&stop_bpstat);
}
+
+/* Record the pc of the program the last time it stopped. This is
+ just used internally by wait_for_inferior, but need to be preserved
+ over calls to it and cleared when the inferior is started. */
+static CORE_ADDR prev_pc;
+
/* Basic routine for continuing the program in various fashions.
ADDR is the address to resume at, or -1 for resume where stopped.
@@ -772,6 +778,10 @@ proceed (CORE_ADDR addr, enum target_sig
inferior. */
gdb_flush (gdb_stdout);
+ /* Refresh prev_pc value which may have been altered by an inferior
+ function call or a return command. */
+ prev_pc = read_pc ();
+
/* Resume inferior. */
resume (oneproc || step || bpstat_should_step (), stop_signal);
@@ -785,11 +795,6 @@ proceed (CORE_ADDR addr, enum target_sig
normal_stop ();
}
}
-
-/* Record the pc of the program the last time it stopped. This is
- just used internally by wait_for_inferior, but need to be preserved
- over calls to it and cleared when the inferior is started. */
-static CORE_ADDR prev_pc;
\f
/* Start remote-debugging of a machine over a serial link. */
next reply other threads:[~2003-05-05 20:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-05 20:48 J. Johnston [this message]
2003-05-06 19:47 ` Andrew Cagney
2003-05-07 18:37 ` J. Johnston
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3EB6CE0A.4070409@redhat.com \
--to=jjohnstn@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox