GDB (xrefs)
/tmp/gdb-7.10/gdb/target-dcache.c
Go to the documentation of this file.
1 /* Copyright (C) 1992-2015 Free Software Foundation, Inc.
2 
3  This file is part of GDB.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 
18 #include "defs.h"
19 #include "target-dcache.h"
20 #include "gdbcmd.h"
21 #include "progspace.h"
22 
23 /* The target dcache is kept per-address-space. This key lets us
24  associate the cache with the address space. */
25 
26 static const struct address_space_data *target_dcache_aspace_key;
27 
28 /* Clean up dcache, represented by ARG, which is associated with
29  ASPACE. */
30 
31 static void
32 target_dcache_cleanup (struct address_space *aspace, void *arg)
33 {
34  dcache_free (arg);
35 }
36 
37 /* Target dcache is initialized or not. */
38 
39 int
41 {
42  DCACHE *dcache = address_space_data (current_program_space->aspace,
44 
45  return (dcache != NULL);
46 }
47 
48 /* Invalidate the target dcache. */
49 
50 void
52 {
53  DCACHE *dcache = address_space_data (current_program_space->aspace,
55 
56  if (dcache != NULL)
57  dcache_invalidate (dcache);
58 }
59 
60 /* Return the target dcache. Return NULL if target dcache is not
61  initialized yet. */
62 
63 DCACHE *
65 {
66  DCACHE *dcache = address_space_data (current_program_space->aspace,
68 
69  return dcache;
70 }
71 
72 /* Return the target dcache. If it is not initialized yet, initialize
73  it. */
74 
75 DCACHE *
77 {
78  DCACHE *dcache = address_space_data (current_program_space->aspace,
80 
81  if (dcache == NULL)
82  {
83  dcache = dcache_init ();
84  set_address_space_data (current_program_space->aspace,
85  target_dcache_aspace_key, dcache);
86  }
87 
88  return dcache;
89 }
90 
91 /* The option sets this. */
92 static int stack_cache_enabled_1 = 1;
93 /* And set_stack_cache updates this.
94  The reason for the separation is so that we don't flush the cache for
95  on->on transitions. */
96 static int stack_cache_enabled = 1;
97 
98 /* This is called *after* the stack-cache has been set.
99  Flush the cache for off->on and on->off transitions.
100  There's no real need to flush the cache for on->off transitions,
101  except cleanliness. */
102 
103 static void
104 set_stack_cache (char *args, int from_tty, struct cmd_list_element *c)
105 {
108 
110 }
111 
112 static void
113 show_stack_cache (struct ui_file *file, int from_tty,
114  struct cmd_list_element *c, const char *value)
115 {
116  fprintf_filtered (file, _("Cache use for stack accesses is %s.\n"), value);
117 }
118 
119 /* Return true if "stack cache" is enabled, otherwise, return false. */
120 
121 int
123 {
124  return stack_cache_enabled;
125 }
126 
127 /* The option sets this. */
128 
129 static int code_cache_enabled_1 = 1;
130 
131 /* And set_code_cache updates this.
132  The reason for the separation is so that we don't flush the cache for
133  on->on transitions. */
134 static int code_cache_enabled = 1;
135 
136 /* This is called *after* the code-cache has been set.
137  Flush the cache for off->on and on->off transitions.
138  There's no real need to flush the cache for on->off transitions,
139  except cleanliness. */
140 
141 static void
142 set_code_cache (char *args, int from_tty, struct cmd_list_element *c)
143 {
146 
148 }
149 
150 /* Show option "code-cache". */
151 
152 static void
153 show_code_cache (struct ui_file *file, int from_tty,
154  struct cmd_list_element *c, const char *value)
155 {
156  fprintf_filtered (file, _("Cache use for code accesses is %s.\n"), value);
157 }
158 
159 /* Return true if "code cache" is enabled, otherwise, return false. */
160 
161 int
163 {
164  return code_cache_enabled;
165 }
166 
167 /* -Wmissing-prototypes */
169 
170 void
172 {
173  add_setshow_boolean_cmd ("stack-cache", class_support,
175 Set cache use for stack access."), _("\
176 Show cache use for stack access."), _("\
177 When on, use the target memory cache for all stack access, regardless of any\n\
178 configured memory regions. This improves remote performance significantly.\n\
179 By default, caching for stack access is on."),
182  &setlist, &showlist);
183 
184  add_setshow_boolean_cmd ("code-cache", class_support,
186 Set cache use for code segment access."), _("\
187 Show cache use for code segment access."), _("\
188 When on, use the target memory cache for all code segment accesses,\n\
189 regardless of any configured memory regions. This improves remote\n\
190 performance significantly. By default, caching for code segment\n\
191 access is on."),
194  &setlist, &showlist);
195 
197  = register_address_space_data_with_cleanup (NULL,
199 }
static int stack_cache_enabled_1
Definition: target-dcache.c:92
DCACHE * dcache_init(void)
Definition: dcache.c:445
struct address_space * aspace
Definition: progspace.h:166
void dcache_free(DCACHE *dcache)
Definition: dcache.c:223
static void set_stack_cache(char *args, int from_tty, struct cmd_list_element *c)
static int code_cache_enabled_1
DCACHE * target_dcache_get_or_init(void)
Definition: target-dcache.c:76
#define _(String)
Definition: gdb_locale.h:40
static void set_code_cache(char *args, int from_tty, struct cmd_list_element *c)
static int stack_cache_enabled
Definition: target-dcache.c:96
static int code_cache_enabled
static void show_code_cache(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
struct cmd_list_element * setlist
Definition: cli-cmds.c:135
void target_dcache_invalidate(void)
Definition: target-dcache.c:51
void initialize_file_ftype(void)
Definition: defs.h:281
initialize_file_ftype _initialize_target_dcache
void fprintf_filtered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2351
int target_dcache_init_p(void)
Definition: target-dcache.c:40
struct cmd_list_element * showlist
Definition: cli-cmds.c:143
Definition: value.c:172
static void target_dcache_cleanup(struct address_space *aspace, void *arg)
Definition: target-dcache.c:32
void dcache_invalidate(DCACHE *dcache)
Definition: dcache.c:248
struct program_space * current_program_space
Definition: progspace.c:35
static const struct address_space_data * target_dcache_aspace_key
Definition: target-dcache.c:26
int code_cache_enabled_p(void)
static void show_stack_cache(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
int stack_cache_enabled_p(void)
DCACHE * target_dcache_get(void)
Definition: target-dcache.c:64
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:541