Re: [PATCH 2/3] skip_prolgoue (amd64)

Yao Qi
2013-12-04T02:34:55Z

On 12/02/2013 03:32 PM, Yao Qi wrote:
> GDB target cache contains both code cache and stack cache. GDB can
> know the JIT event by means of jit event breakpoint, but GDB can't know
> whether a thread's stack is modified (by other threads). So we have
> to flush target cache before handling*every* event :-/ I'll send a
> follow-up patch.

When I finished the patch below, I wondered whether this is the right
way to go.

Nowadays, in non-stop mode, GDB flushes target cache between
each command. With the patch applied, GDB flushes target cache between
each event. Then, I realize that GDB flushes cache at any changes (GDB
commands from user and events from inferior) in non-stop mode, so I
can't figure out a case that cache can be used. Do we still need target
cache in non-stop mode?

--
Yao (é½å°§)

Subject: [PATCH] Flush target dcache in non-stop before handling events

gdb:

2013-12-04 Yao Qi <yao@codesourcery.com>

* infrun.c: Include "target-dcache.h".
(fetch_inferior_event): Call target_dcache_invalidate in
non-stop.
---
gdb/infrun.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 3b55583..2ed0537 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -60,6 +60,7 @@
#include "objfiles.h"
#include "completer.h"
#include "target-descriptions.h"
+#include "target-dcache.h"

/* Prototypes for local functions */

@@ -2806,6 +2807,16 @@ fetch_inferior_event (void *client_data)

overlay_cache_invalid = 1;

+ if (non_stop)
+ {
+ /* In non-stop mode, one thread stops and caches the contents of
+ stack or code, while other running threads may change the
+ code (through JIT) or stack. The target cache can get stale
+ without us being able to detect it. Flush target cache
+ before handling each event. */
+ target_dcache_invalidate ();
+ }
+
make_cleanup_restore_integer (&execution_direction);
execution_direction = target_execution_direction ();

--
1.7.7.6