From b48d48ebed2efed429a1e6b92603d784b703a4ab Mon Sep 17 00:00:00 2001 From: Markus Metzger Date: Mon, 11 Mar 2013 08:39:38 +0000 Subject: [PATCH] Add a new function to target.h to add an alias command for a target and mark it deprecated. This is useful when renaming targets. gdb/ * target.h (add_deprecated_target_alias): New. * target.c (add_deprecated_target_alias): New. --- gdb/ChangeLog | 5 +++++ gdb/target.c | 15 +++++++++++++++ gdb/target.h | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0691d64b264..8655973fc8c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2013-03-11 Markus Metzger + + * target.h (add_deprecated_target_alias): New. + * target.c (add_deprecated_target_alias): New. + 2013-03-11 Markus Metzger * common/linux-btrace.c: Include sys/ptrace, sys/types, sys/wait.h, diff --git a/gdb/target.c b/gdb/target.c index 524caec7122..dd201847ac2 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -434,6 +434,21 @@ information on the arguments for a particular protocol, type\n\ add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, &targetlist); } +/* See target.h. */ + +void +add_deprecated_target_alias (struct target_ops *t, char *alias) +{ + struct cmd_list_element *c; + char *alt; + + /* If we use add_alias_cmd, here, we do not get the deprecated warning, + see PR cli/15104. */ + c = add_cmd (alias, no_class, t->to_open, t->to_doc, &targetlist); + alt = xstrprintf ("target %s", t->to_shortname); + deprecate_cmd (c, alt); +} + /* Stub functions */ void diff --git a/gdb/target.h b/gdb/target.h index ceecca4f321..e98095e35f8 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1788,6 +1788,11 @@ int target_verify_memory (const gdb_byte *data, extern void add_target (struct target_ops *); +/* Adds a command ALIAS for target T and marks it deprecated. This is useful + for maintaining backwards compatibility when renaming targets. */ + +extern void add_deprecated_target_alias (struct target_ops *t, char *alias); + extern void push_target (struct target_ops *); extern int unpush_target (struct target_ops *); -- 2.30.2