From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 6/9] gdb: Convert language la_watch_location_expression field to a method
Date: Tue, 2 Jun 2020 14:32:24 +0100 [thread overview]
Message-ID: <5b3c9e4a218c779ef0bc077cef664df3fef8ceb4.1591104079.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1591104078.git.andrew.burgess@embecosm.com>
This commit changes the language_data::la_watch_location_expression
function pointer member variable into a member function of
language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_watch_location_expression): Rename to
ada_language::watch_location_expression.
(ada_language_data): Delete la_watch_location_expression
initializer.
(ada_language::watch_location_expression): New member function,
implementation from ada_watch_location_expression.
* breakpoint.c (watch_command_1): Update call to
watch_location_expression.
* c-lang.c (c_watch_location_expression): Rename to
language_defn::watch_location_expression.
(c_language_data): Delete la_watch_location_expression
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* c-lang.h (c_watch_location_expression): Delete declaration.
* d-lang.c (d_language_data): Delete la_watch_location_expression
initializer.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (language_defn::watch_location_expression): Member
function implementation from c_watch_location_expression.
(unknown_language_data): Delete la_watch_location_expression
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_watch_location_expression
field.
(language_defn::watch_location_expression): Declare new member
function.
* m2-lang.c (m2_language_data): Delete
la_watch_location_expression initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_watch_location_expression): Rename to
rust_language::watch_location_expression.
(rust_language_data): Delete la_watch_location_expression
initializer.
(rust_language::watch_location_expression): New member function,
implementation from rust_watch_location_expression.
---
gdb/ChangeLog | 43 +++++++++++++++++++++++++++++++++++++++++++
gdb/ada-lang.c | 23 +++++++++++------------
gdb/breakpoint.c | 2 +-
gdb/c-lang.c | 15 ---------------
gdb/c-lang.h | 3 ---
gdb/d-lang.c | 1 -
gdb/f-lang.c | 1 -
gdb/go-lang.c | 1 -
gdb/language.c | 15 +++++++++++++--
gdb/language.h | 12 ++++++------
gdb/m2-lang.c | 1 -
gdb/objc-lang.c | 1 -
gdb/opencl-lang.c | 1 -
gdb/p-lang.c | 1 -
gdb/rust-lang.c | 27 ++++++++++++---------------
15 files changed, 86 insertions(+), 61 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 08421c3fbf2..6c95d20162d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -488,17 +488,6 @@ add_angle_brackets (const char *str)
return string_printf ("<%s>", str);
}
-/* la_watch_location_expression for Ada. */
-
-static gdb::unique_xmalloc_ptr<char>
-ada_watch_location_expression (struct type *type, CORE_ADDR addr)
-{
- type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
- std::string name = type_to_string (type);
- return gdb::unique_xmalloc_ptr<char>
- (xstrprintf ("{%s} %s", name.c_str (), core_addr_to_string (addr)));
-}
-
/* Assuming V points to an array of S objects, make sure that it contains at
least M objects, updating V and S as necessary. */
@@ -13794,7 +13783,6 @@ extern const struct language_data ada_language_data =
ada_op_print_tab, /* expression operators for printing */
0, /* c-style arrays */
1, /* String lower bound */
- ada_watch_location_expression,
&ada_varobj_ops,
ada_is_string_type,
"(...)" /* la_struct_too_deep_ellipsis */
@@ -14113,6 +14101,17 @@ class ada_language : public language_defn
}
}
+ /* See language.h. */
+
+ gdb::unique_xmalloc_ptr<char> watch_location_expression
+ (struct type *type, CORE_ADDR addr) const override
+ {
+ type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
+ std::string name = type_to_string (type);
+ return gdb::unique_xmalloc_ptr<char>
+ (xstrprintf ("{%s} %s", name.c_str (), core_addr_to_string (addr)));
+ }
+
protected:
/* See language.h. */
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index aead882acd8..6d81323dd92 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -10738,7 +10738,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
CORE_ADDR addr = value_as_address (val.get ());
w->exp_string_reparse
- = current_language->la_watch_location_expression (t, addr).release ();
+ = current_language->watch_location_expression (t, addr).release ();
w->exp_string = xstrprintf ("-location %.*s",
(int) (exp_end - exp_start), exp_start);
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index d6b32eef175..13d13435fe4 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -727,17 +727,6 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
return evaluate_subexp_standard (expect_type, exp, pos, noside);
}
\f
-/* la_watch_location_expression for C. */
-
-gdb::unique_xmalloc_ptr<char>
-c_watch_location_expression (struct type *type, CORE_ADDR addr)
-{
- type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
- std::string name = type_to_string (type);
- return gdb::unique_xmalloc_ptr<char>
- (xstrprintf ("* (%s *) %s", name.c_str (), core_addr_to_string (addr)));
-}
-
/* See c-lang.h. */
bool
@@ -914,7 +903,6 @@ extern const struct language_data c_language_data =
c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
- c_watch_location_expression,
&c_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
@@ -1026,7 +1014,6 @@ extern const struct language_data cplus_language_data =
c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
- c_watch_location_expression,
&cplus_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
@@ -1226,7 +1213,6 @@ extern const struct language_data asm_language_data =
c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
- c_watch_location_expression,
&default_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
@@ -1293,7 +1279,6 @@ extern const struct language_data minimal_language_data =
c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
- c_watch_location_expression,
&default_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 31ec6f2cf74..6c5d0d814c4 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -116,9 +116,6 @@ extern void c_emit_char (int c, struct type *type,
extern const struct op_print c_op_print_tab[];
-extern gdb::unique_xmalloc_ptr<char> c_watch_location_expression
- (struct type *type, CORE_ADDR addr);
-
/* These are in c-typeprint.c: */
extern void c_type_print_base (struct type *, struct ui_file *,
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 67c82e4215e..001af06a82a 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -157,7 +157,6 @@ extern const struct language_data d_language_data =
d_op_print_tab, /* Expression operators for printing. */
1, /* C-style arrays. */
0, /* String lower bound. */
- c_watch_location_expression,
&default_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 0540ab233db..e421e5f9645 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -578,7 +578,6 @@ extern const struct language_data f_language_data =
f_op_print_tab, /* expression operators for printing */
0, /* arrays are first-class (not c-style) */
1, /* String lower bound */
- c_watch_location_expression,
&default_varobj_ops,
f_is_string_type_p,
"(...)" /* la_struct_too_deep_ellipsis */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index a1af67deaae..92eeae4d0a8 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -542,7 +542,6 @@ extern const struct language_data go_language_data =
go_op_print_tab, /* Expression operators for printing. */
1, /* C-style arrays. */
0, /* String lower bound. */
- c_watch_location_expression,
&default_varobj_ops,
go_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
diff --git a/gdb/language.c b/gdb/language.c
index f4e99fc392f..6320577addf 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -622,6 +622,19 @@ language_defn::print_array_index (struct type *index_type, LONGEST index,
fprintf_filtered (stream, "] = ");
}
+/* See language.h. */
+
+gdb::unique_xmalloc_ptr<char>
+language_defn::watch_location_expression (struct type *type,
+ CORE_ADDR addr) const
+{
+ /* Generates an expression that assumes a C like syntax is valid. */
+ type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
+ std::string name = type_to_string (type);
+ return gdb::unique_xmalloc_ptr<char>
+ (xstrprintf ("* (%s *) %s", name.c_str (), core_addr_to_string (addr)));
+}
+
/* The default implementation of the get_symbol_name_matcher_inner method
from the language_defn class. Matches with strncmp_iw. */
@@ -779,7 +792,6 @@ extern const struct language_data unknown_language_data =
unk_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
- c_watch_location_expression,
&default_varobj_ops,
default_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
@@ -850,7 +862,6 @@ extern const struct language_data auto_language_data =
unk_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
- c_watch_location_expression,
&default_varobj_ops,
default_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
diff --git a/gdb/language.h b/gdb/language.h
index 5872db39dbb..1cd3785ab0b 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -319,12 +319,6 @@ struct language_data
/* Index to use for extracting the first element of a string. */
char string_lower_bound;
- /* Return an expression that can be used for a location
- watchpoint. TYPE is a pointer type that points to the memory
- to watch, and ADDR is the address of the watched memory. */
- gdb::unique_xmalloc_ptr<char> (*la_watch_location_expression)
- (struct type *type, CORE_ADDR addr);
-
/* Various operations on varobj. */
const struct lang_varobj_ops *la_varobj_ops;
@@ -540,6 +534,12 @@ struct language_defn : language_data
(tracker, mode, name_match_type, text, word, "", code);
}
+ /* Return an expression that can be used for a location
+ watchpoint. TYPE is a pointer type that points to the memory
+ to watch, and ADDR is the address of the watched memory. */
+ virtual gdb::unique_xmalloc_ptr<char> watch_location_expression
+ (struct type *type, CORE_ADDR addr) const;
+
/* List of all known languages. */
static const struct language_defn *languages[nr_languages];
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index a028a2f2e22..e4c783964ce 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -376,7 +376,6 @@ extern const struct language_data m2_language_data =
m2_op_print_tab, /* expression operators for printing */
0, /* arrays are first-class (not c-style) */
0, /* String lower bound */
- c_watch_location_expression,
&default_varobj_ops,
m2_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 5f9e9710366..fa5aa9bc06e 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -351,7 +351,6 @@ extern const struct language_data objc_language_data =
objc_op_print_tab, /* Expression operators for printing */
1, /* C-style arrays */
0, /* String lower bound */
- c_watch_location_expression,
&default_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index d93ce0bc478..4cdfc045e04 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1030,7 +1030,6 @@ extern const struct language_data opencl_language_data =
c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
- c_watch_location_expression,
&default_varobj_ops,
c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index cdcf726ce9c..72c484a88cb 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -407,7 +407,6 @@ extern const struct language_data pascal_language_data =
pascal_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
- c_watch_location_expression,
&default_varobj_ops,
pascal_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index a4e473d2f6f..373d6101018 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2006,20 +2006,6 @@ rust_lookup_symbol_nonlocal (const struct language_defn *langdef,
\f
-/* la_watch_location_expression for Rust. */
-
-static gdb::unique_xmalloc_ptr<char>
-rust_watch_location_expression (struct type *type, CORE_ADDR addr)
-{
- type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
- std::string name = type_to_string (type);
- return gdb::unique_xmalloc_ptr<char>
- (xstrprintf ("*(%s as *mut %s)", core_addr_to_string (addr),
- name.c_str ()));
-}
-
-\f
-
static const struct exp_descriptor exp_descriptor_rust =
{
rust_print_subexp,
@@ -2062,7 +2048,6 @@ extern const struct language_data rust_language_data =
c_op_print_tab, /* expression operators for printing */
1, /* c-style arrays */
0, /* String lower bound */
- rust_watch_location_expression,
&default_varobj_ops,
rust_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
@@ -2143,6 +2128,18 @@ class rust_language : public language_defn
rust_internal_print_type (type, varstring, stream, show, level,
flags, false, &podata);
}
+
+ /* See language.h. */
+
+ gdb::unique_xmalloc_ptr<char> watch_location_expression
+ (struct type *type, CORE_ADDR addr) const override
+ {
+ type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
+ std::string name = type_to_string (type);
+ return gdb::unique_xmalloc_ptr<char>
+ (xstrprintf ("*(%s as *mut %s)", core_addr_to_string (addr),
+ name.c_str ()));
+ }
};
/* Single instance of the Rust language class. */
--
2.25.4
next prev parent reply other threads:[~2020-06-02 13:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-02 13:32 [PATCH 0/9] Further Conversion of Language Class Hierarchy Andrew Burgess
2020-06-02 13:32 ` [PATCH 1/9] gdb: Convert language la_class_name_from_physname field to a method Andrew Burgess
2020-06-02 13:32 ` [PATCH 2/9] gdb: Convert language la_compute_program " Andrew Burgess
2020-06-02 13:32 ` [PATCH 3/9] gdb: Convert language la_get_symbol_name_matcher " Andrew Burgess
2020-06-15 14:22 ` Tom Tromey
2020-06-02 13:32 ` [PATCH 4/9] gdb: Convert language la_word_break_characters " Andrew Burgess
2020-06-02 13:32 ` [PATCH 5/9] gdb: Convert language la_collect_symbol_completion_matches " Andrew Burgess
2020-06-02 13:32 ` Andrew Burgess [this message]
2020-06-02 13:32 ` [PATCH 7/9] gdb: Convert language la_value_print " Andrew Burgess
2020-06-02 13:32 ` [PATCH 8/9] gdb: Convert language la_value_print_inner " Andrew Burgess
2020-06-02 13:32 ` [PATCH 9/9] gdb: Convert language la_lookup_symbol_nonlocal " Andrew Burgess
2020-06-10 2:54 ` [PATCH 0/9] Further Conversion of Language Class Hierarchy Simon Marchi
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=5b3c9e4a218c779ef0bc077cef664df3fef8ceb4.1591104079.git.andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).