GDB (xrefs)
Loading...
Searching...
No Matches
target-dcache.c
Go to the documentation of this file.
1/* Copyright (C) 1992-2023 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#include "cli/cli-cmds.h"
23
24/* The target dcache is kept per-address-space. This key lets us
25 associate the cache with the address space. */
26
29
30/* Target dcache is initialized or not. */
31
32int
34{
35 DCACHE *dcache
37
38 return (dcache != NULL);
39}
40
41/* Invalidate the target dcache. */
42
43void
45{
46 DCACHE *dcache
48
49 if (dcache != NULL)
50 dcache_invalidate (dcache);
51}
52
53/* Return the target dcache. Return NULL if target dcache is not
54 initialized yet. */
55
56DCACHE *
61
62/* Return the target dcache. If it is not initialized yet, initialize
63 it. */
64
65DCACHE *
67{
68 DCACHE *dcache
70
71 if (dcache == NULL)
72 {
73 dcache = dcache_init ();
75 }
76
77 return dcache;
78}
79
80/* The option sets this. */
81static bool stack_cache_enabled_1 = true;
82/* And set_stack_cache updates this.
83 The reason for the separation is so that we don't flush the cache for
84 on->on transitions. */
85static int stack_cache_enabled = 1;
86
87/* This is called *after* the stack-cache has been set.
88 Flush the cache for off->on and on->off transitions.
89 There's no real need to flush the cache for on->off transitions,
90 except cleanliness. */
91
92static void
100
101static void
102show_stack_cache (struct ui_file *file, int from_tty,
103 struct cmd_list_element *c, const char *value)
104{
105 gdb_printf (file, _("Cache use for stack accesses is %s.\n"), value);
106}
107
108/* Return true if "stack cache" is enabled, otherwise, return false. */
109
110int
112{
113 return stack_cache_enabled;
114}
115
116/* The option sets this. */
117
118static bool code_cache_enabled_1 = true;
119
120/* And set_code_cache updates this.
121 The reason for the separation is so that we don't flush the cache for
122 on->on transitions. */
123static int code_cache_enabled = 1;
124
125/* This is called *after* the code-cache has been set.
126 Flush the cache for off->on and on->off transitions.
127 There's no real need to flush the cache for on->off transitions,
128 except cleanliness. */
129
130static void
131set_code_cache (const char *args, int from_tty, struct cmd_list_element *c)
132{
135
137}
138
139/* Show option "code-cache". */
140
141static void
142show_code_cache (struct ui_file *file, int from_tty,
143 struct cmd_list_element *c, const char *value)
144{
145 gdb_printf (file, _("Cache use for code accesses is %s.\n"), value);
146}
147
148/* Return true if "code cache" is enabled, otherwise, return false. */
149
150int
152{
153 return code_cache_enabled;
154}
155
156/* Implement the 'maint flush dcache' command. */
157
158static void
159maint_flush_dcache_command (const char *command, int from_tty)
160{
162 if (from_tty)
163 gdb_printf (_("The dcache was flushed.\n"));
164}
165
167void
169{
172Set cache use for stack access."), _("\
173Show cache use for stack access."), _("\
174When on, use the target memory cache for all stack access, regardless of any\n\
175configured memory regions. This improves remote performance significantly.\n\
176By default, caching for stack access is on."),
179 &setlist, &showlist);
180
183Set cache use for code segment access."), _("\
184Show cache use for code segment access."), _("\
185When on, use the target memory cache for all code segment accesses,\n\
186regardless of any configured memory regions. This improves remote\n\
187performance significantly. By default, caching for code segment\n\
188access is on."),
191 &setlist, &showlist);
192
194 _("\
195Force gdb to flush its target memory data cache.\n\
196\n\
197The dcache caches all target memory accesses where possible, this\n\
198includes the stack-cache and the code-cache."),
200}
void set(unsigned key, void *datum)
Definition registry.h:204
void * get(unsigned key)
Definition registry.h:211
struct cmd_list_element * showlist
Definition cli-cmds.c:127
struct cmd_list_element * setlist
Definition cli-cmds.c:119
struct cmd_list_element * maintenanceflushlist
Definition cli-cmds.c:159
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition cli-decode.c:233
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:809
@ class_maintenance
Definition command.h:65
@ class_support
Definition command.h:58
DCACHE * dcache_init(void)
Definition dcache.c:448
void dcache_invalidate(DCACHE *dcache)
Definition dcache.c:249
struct dcache_struct DCACHE
Definition dcache.h:26
struct program_space * current_program_space
Definition progspace.c:40
struct address_space * aspace
Definition progspace.h:339
Definition value.h:130
static void maint_flush_dcache_command(const char *command, int from_tty)
static const registry< address_space >::key< DCACHE, dcache_deleter > target_dcache_aspace_key
void _initialize_target_dcache()
int target_dcache_init_p(void)
static void set_code_cache(const char *args, int from_tty, struct cmd_list_element *c)
void target_dcache_invalidate(void)
DCACHE * target_dcache_get(void)
static void show_code_cache(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
DCACHE * target_dcache_get_or_init(void)
int stack_cache_enabled_p(void)
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)
static int code_cache_enabled
static bool code_cache_enabled_1
static bool stack_cache_enabled_1
static int stack_cache_enabled
static void set_stack_cache(const char *args, int from_tty, struct cmd_list_element *c)
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1886