From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [PATCH 04/18] add new "unload" command (symetry of existing "load" command)
Date: Thu, 24 Feb 2011 17:50:00 -0000 [thread overview]
Message-ID: <1298569763-18784-5-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <1298569763-18784-1-git-send-email-brobecker@adacore.com>
As the title suggests, this patch adds a new "unload" command which
is expected to do the opposite of the load command, on the targets
that support it. VxWorks targets allow us to unload modules, and
thus this target method will be used there.
gdb/ChangeLog:
* target.h (struct target_ops): Add "to_unload" field.
(target_unload): Add declaration.
* target.c (debug_to_unload, target_unload): New functions.
(update_current_target): Add support for to_unload method.
(setup_target_debug): Set current_target.to_unload.
* symfile.c (unload_command): New function.
(_initialize_symfile): Add "unload" command.
gdb/doc/ChangeLog:
* gdb.texinfo (Target Commands): Document new "unload" command.
---
gdb/doc/gdb.texinfo | 13 +++++++++++++
gdb/symfile.c | 18 ++++++++++++++++++
gdb/target.c | 22 ++++++++++++++++++++++
gdb/target.h | 10 ++++++++++
4 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index c727dc8..32454c3 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -15842,6 +15842,19 @@ Depending on the remote side capabilities, @value{GDBN} may be able to
load programs into flash memory.
@code{load} does not repeat if you press @key{RET} again after using it.
+
+@item unload @var{filename}
+@kindex unload @var{filename}
+@cindex unload object file from target
+Depending on what remote debugging facilities are configured into
+@value{GDBN}, the @code{unload} command may be available. Where it exists,
+it does the opposite of the @code{load} command.
+
+If your @value{GDBN} does not have an @code{unload} command, attempting
+to execute it triggers the error message ``@code{You can't do that when
+your target is @dots{}}''
+
+@code{unload} does not repeat if you press @key{RET} again after using it.
@end table
@node Byte Order
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 579aaa4..2e43e83 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1788,6 +1788,20 @@ load_command (char *arg, int from_tty)
overlay_cache_invalid = 1;
}
+/* Implement the "unload" command. */
+
+static void
+unload_command (char *arg, int from_tty)
+{
+ dont_repeat ();
+
+ target_unload (arg, from_tty);
+
+ /* After unloading some object files, we don't really know which
+ overlays are mapped any more. */
+ overlay_cache_invalid = 1;
+}
+
/* This version of "load" should be usable for any target. Currently
it is just used for remote targets, not inftarg.c or core files,
on the theory that only in that case is it useful.
@@ -3672,6 +3686,10 @@ for access from GDB.\n\
A load OFFSET may also be given."), &cmdlist);
set_cmd_completer (c, filename_completer);
+ c = add_cmd ("unload", class_files, unload_command, _("\
+Unload FILE from the target."), &cmdlist);
+ set_cmd_completer (c, filename_completer);
+
add_setshow_boolean_cmd ("symbol-reloading", class_support,
&symbol_reloading, _("\
Set dynamic symbol table reloading multiple times in one run."), _("\
diff --git a/gdb/target.c b/gdb/target.c
index a4e2ae9..959e5ff 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -149,6 +149,8 @@ static void debug_to_terminal_info (char *, int);
static void debug_to_load (char *, int);
+static void debug_to_unload (char *, int);
+
static int debug_to_lookup_symbol (char *, CORE_ADDR *);
static int debug_to_can_run (void);
@@ -468,6 +470,13 @@ target_load (char *arg, int from_tty)
}
void
+target_unload (char *arg, int from_tty)
+{
+ target_dcache_invalidate ();
+ (*current_target.to_unload) (arg, from_tty);
+}
+
+void
target_create_inferior (char *exec_file, char *args,
char **env, int from_tty)
{
@@ -615,6 +624,7 @@ update_current_target (void)
INHERIT (to_terminal_info, t);
/* Do not inherit to_kill. */
INHERIT (to_load, t);
+ INHERIT (to_unload, t);
INHERIT (to_lookup_symbol, t);
/* Do no inherit to_create_inferior. */
INHERIT (to_post_startup_inferior, t);
@@ -768,6 +778,9 @@ update_current_target (void)
de_fault (to_load,
(void (*) (char *, int))
tcomplain);
+ de_fault (to_unload,
+ (void (*) (char *, int))
+ tcomplain);
de_fault (to_lookup_symbol,
(int (*) (char *, CORE_ADDR *))
nosymbol);
@@ -3788,6 +3801,14 @@ debug_to_load (char *args, int from_tty)
fprintf_unfiltered (gdb_stdlog, "target_load (%s, %d)\n", args, from_tty);
}
+static void
+debug_to_unload (char *args, int from_tty)
+{
+ debug_target.to_unload (args, from_tty);
+
+ fprintf_unfiltered (gdb_stdlog, "target_unload (%s, %d)\n", args, from_tty);
+}
+
static int
debug_to_lookup_symbol (char *name, CORE_ADDR *addrp)
{
@@ -3999,6 +4020,7 @@ setup_target_debug (void)
current_target.to_terminal_save_ours = debug_to_terminal_save_ours;
current_target.to_terminal_info = debug_to_terminal_info;
current_target.to_load = debug_to_load;
+ current_target.to_unload = debug_to_unload;
current_target.to_lookup_symbol = debug_to_lookup_symbol;
current_target.to_post_startup_inferior = debug_to_post_startup_inferior;
current_target.to_insert_fork_catchpoint = debug_to_insert_fork_catchpoint;
diff --git a/gdb/target.h b/gdb/target.h
index e856dde..78fccd3 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -479,6 +479,7 @@ struct target_ops
void (*to_terminal_info) (char *, int);
void (*to_kill) (struct target_ops *);
void (*to_load) (char *, int);
+ void (*to_unload) (char *, int);
int (*to_lookup_symbol) (char *, CORE_ADDR *);
void (*to_create_inferior) (struct target_ops *,
char *, char *, char **, int);
@@ -1016,6 +1017,15 @@ extern void target_kill (void);
extern void target_load (char *arg, int from_tty);
+/* Unload an object file.
+
+ ARG contains command-line arguments, to be broken down with buildargv.
+ The first non-switch argument is the object filename to be unloaded.
+ The target may define switches, or other non-switch arguments, as
+ it pleases. */
+
+extern void target_unload (char *arg, int from_tty);
+
/* Look up a symbol in the target's symbol table. NAME is the symbol
name. ADDRP is a CORE_ADDR * pointing to where the value of the
symbol should be returned. The result is 0 if successful, nonzero
--
1.7.0.4
next prev parent reply other threads:[~2011-02-24 17:50 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-24 17:49 Add support for VxWorks 5.x, 6.x and 653 Joel Brobecker
2011-02-24 17:49 ` [PATCH 01/18] Some ada-lang/ada-tasks routines needed by the VxWorks target Joel Brobecker
2011-02-24 17:50 ` [PATCH 02/18] New command_post observer Joel Brobecker
2011-02-24 18:58 ` Tom Tromey
2011-02-24 17:50 ` [PATCH 03/18] New general purpose routines in utils.c Joel Brobecker
2011-02-24 19:06 ` Tom Tromey
2011-02-24 17:50 ` Joel Brobecker [this message]
2011-02-24 19:22 ` [PATCH 04/18] add new "unload" command (symetry of existing "load" command) Eli Zaretskii
2011-02-24 17:51 ` [PATCH 05/18] new struct bp_target_info target_private_data field Joel Brobecker
2011-02-24 17:54 ` [PATCH 08/18] Add options to control Vxworks related settings Joel Brobecker
2011-02-24 17:54 ` [PATCH 06/18] New module remote-wtx-utils Joel Brobecker
2011-02-24 19:26 ` Tom Tromey
2011-02-24 17:54 ` [PATCH 09/18] VxWorks breakpoint-handling module Joel Brobecker
2011-02-24 17:55 ` [PATCH 10/18] "multi-tasks-mode" support Joel Brobecker
2011-02-24 17:56 ` [PATCH 07/18] remote-wtxapi: The WTX API abstraction layer Joel Brobecker
2011-02-24 19:44 ` Tom Tromey
2011-02-24 17:56 ` [PATCH 11/18] Add partition support Joel Brobecker
2011-02-25 16:17 ` Tom Tromey
2011-02-24 17:57 ` [PATCH 12/18] remote-wtx-hw: register fetch/store support Joel Brobecker
2011-02-24 17:57 ` [PATCH 14/18] WTX-TCL support module Joel Brobecker
2011-02-25 15:59 ` Tom Tromey
2011-02-25 18:58 ` Joel Brobecker
2011-02-28 15:37 ` Tom Tromey
2011-02-24 17:57 ` [PATCH 13/18] Add new "wtx" target Joel Brobecker
2011-02-25 16:15 ` Tom Tromey
2011-02-25 17:38 ` Joel Brobecker
2011-02-24 17:58 ` [PATCH 15/18] Add support for VxWorks 6 Joel Brobecker
2011-02-24 17:59 ` [PATCH 17/18] Configury and Makefile updates for VxWorks Joel Brobecker
2011-02-24 17:59 ` [PATCH 16/18] Add tdep files for x86 and powerpc Joel Brobecker
2011-02-24 18:58 ` Mark Kettenis
2011-02-25 8:29 ` Joel Brobecker
2011-02-24 18:04 ` [PATCH 18/18] document the new VxWorks port Joel Brobecker
2011-02-24 20:27 ` Eli Zaretskii
2011-02-25 11:12 ` Jerome Guitton
2011-02-25 11:27 ` Eli Zaretskii
2011-02-25 11:38 ` Jerome Guitton
2011-02-25 11:38 ` Joel Brobecker
2011-02-25 12:08 ` Eli Zaretskii
2011-02-25 13:26 ` Jerome Guitton
2011-02-25 11:44 ` Eli Zaretskii
2011-02-25 11:49 ` Joel Brobecker
2011-02-25 11:55 ` Jerome Guitton
2011-02-25 11:56 ` Joel Brobecker
2011-02-25 12:01 ` Pedro Alves
2011-02-25 14:21 ` Joel Brobecker
2011-02-25 14:44 ` Pedro Alves
2011-02-25 15:15 ` Joel Brobecker
2011-02-25 12:05 ` Jerome Guitton
2011-02-25 12:15 ` Eli Zaretskii
2011-02-25 12:56 ` Joel Brobecker
2011-02-25 13:20 ` Eli Zaretskii
2011-02-25 14:11 ` Jerome Guitton
2011-03-03 12:16 ` Joel Brobecker
2011-03-03 13:44 ` Eli Zaretskii
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=1298569763-18784-5-git-send-email-brobecker@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/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