aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-06-18 22:01:33 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-06-23 13:34:11 +0100
commit39e7eccae602562368438c955b31f1d0e37feaa5 (patch)
tree3236e9c2818f16148ab08612b7a4ee8e3ec84540
parent4ffc13fb0e4a1c5158cdf00f2751378653101207 (diff)
downloadgdb-39e7eccae602562368438c955b31f1d0e37feaa5.zip
gdb-39e7eccae602562368438c955b31f1d0e37feaa5.tar.gz
gdb-39e7eccae602562368438c955b31f1d0e37feaa5.tar.bz2
gdb: Convert language la_is_string_type_p field to a method
This commit changes the language_data::la_is_string_type_p 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_language_data): Delete la_is_string_type_p initializer. (ada_language::is_string_type_p): New member function. * c-lang.c (c_language_data): Delete la_is_string_type_p initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_is_string_type_p): Delete function, implementation moved to f_language::is_string_type_p. (f_language_data): Delete la_is_string_type_p initializer. (f_language::is_string_type_p): New member function, implementation from f_is_string_type_p. * go-lang.c (go_is_string_type_p): Delete function, implementation moved to go_language::is_string_type_p. (go_language_data): Delete la_is_string_type_p initializer. (go_language::is_string_type_p): New member function, implementation from go_is_string_type_p. * language.c (language_defn::is_string_type_p): Define new member function. (default_is_string_type_p): Make static, add comment copied from header file. (unknown_language_data): Delete la_is_string_type_p initializer. (unknown_language::is_string_type_p): New member function. (auto_language_data): Delete la_is_string_type_p initializer. (auto_language::is_string_type_p): New member function. * language.h (language_data): Delete la_is_string_type_p field. (language_defn::is_string_type_p): Declare new function. (default_is_string_type_p): Delete desclaration, move comment to definition. * m2-lang.c (m2_is_string_type_p): Delete function, implementation moved to m2_language::is_string_type_p. (m2_language_data): Delete la_is_string_type_p initializer. (m2_language::is_string_type_p): New member function, implementation from m2_is_string_type_p. * objc-lang.c (objc_language_data): Delete la_is_string_type_p initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_is_string_type_p): Delete function, implementation moved to pascal_language::is_string_type_p. (pascal_language_data): Delete la_is_string_type_p initializer. (pascal_language::is_string_type_p): New member function, implementation from pascal_is_string_type_p. * rust-lang.c (rust_is_string_type_p): Delete function, implementation moved to rust_language::is_string_type_p. (rust_language_data): Delete la_is_string_type_p initializer. (rust_language::is_string_type_p): New member function, implementation from rust_is_string_type_p. * valprint.c (val_print_scalar_or_string_type_p): Update call to is_string_type_p.
-rw-r--r--gdb/ChangeLog54
-rw-r--r--gdb/ada-lang.c9
-rw-r--r--gdb/c-lang.c4
-rw-r--r--gdb/d-lang.c1
-rw-r--r--gdb/f-lang.c22
-rw-r--r--gdb/go-lang.c21
-rw-r--r--gdb/language.c29
-rw-r--r--gdb/language.h10
-rw-r--r--gdb/m2-lang.c41
-rw-r--r--gdb/objc-lang.c1
-rw-r--r--gdb/opencl-lang.c1
-rw-r--r--gdb/p-lang.c18
-rw-r--r--gdb/rust-lang.c40
-rw-r--r--gdb/valprint.c2
14 files changed, 156 insertions, 97 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index de348bb..af34af8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,59 @@
2020-06-23 Andrew Burgess <andrew.burgess@embecosm.com>
+ * ada-lang.c (ada_language_data): Delete la_is_string_type_p
+ initializer.
+ (ada_language::is_string_type_p): New member function.
+ * c-lang.c (c_language_data): Delete la_is_string_type_p
+ initializer.
+ (cplus_language_data): Likewise.
+ (asm_language_data): Likewise.
+ (minimal_language_data): Likewise.
+ * d-lang.c (d_language_data): Likewise.
+ * f-lang.c (f_is_string_type_p): Delete function, implementation
+ moved to f_language::is_string_type_p.
+ (f_language_data): Delete la_is_string_type_p initializer.
+ (f_language::is_string_type_p): New member function,
+ implementation from f_is_string_type_p.
+ * go-lang.c (go_is_string_type_p): Delete function, implementation
+ moved to go_language::is_string_type_p.
+ (go_language_data): Delete la_is_string_type_p initializer.
+ (go_language::is_string_type_p): New member function,
+ implementation from go_is_string_type_p.
+ * language.c (language_defn::is_string_type_p): Define new member
+ function.
+ (default_is_string_type_p): Make static, add comment copied from
+ header file.
+ (unknown_language_data): Delete la_is_string_type_p initializer.
+ (unknown_language::is_string_type_p): New member function.
+ (auto_language_data): Delete la_is_string_type_p initializer.
+ (auto_language::is_string_type_p): New member function.
+ * language.h (language_data): Delete la_is_string_type_p field.
+ (language_defn::is_string_type_p): Declare new function.
+ (default_is_string_type_p): Delete desclaration, move comment to
+ definition.
+ * m2-lang.c (m2_is_string_type_p): Delete function, implementation
+ moved to m2_language::is_string_type_p.
+ (m2_language_data): Delete la_is_string_type_p initializer.
+ (m2_language::is_string_type_p): New member function,
+ implementation from m2_is_string_type_p.
+ * objc-lang.c (objc_language_data): Delete la_is_string_type_p
+ initializer.
+ * opencl-lang.c (opencl_language_data): Likewise.
+ * p-lang.c (pascal_is_string_type_p): Delete function,
+ implementation moved to pascal_language::is_string_type_p.
+ (pascal_language_data): Delete la_is_string_type_p initializer.
+ (pascal_language::is_string_type_p): New member function,
+ implementation from pascal_is_string_type_p.
+ * rust-lang.c (rust_is_string_type_p): Delete function,
+ implementation moved to rust_language::is_string_type_p.
+ (rust_language_data): Delete la_is_string_type_p initializer.
+ (rust_language::is_string_type_p): New member function,
+ implementation from rust_is_string_type_p.
+ * valprint.c (val_print_scalar_or_string_type_p): Update call to
+ is_string_type_p.
+
+2020-06-23 Andrew Burgess <andrew.burgess@embecosm.com>
+
* ada-lang.c (ada_language_data): Delete la_print_typedef
initializer.
(ada_language::print_typedef): New member function.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 752bf44..9b0c2ef 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13687,7 +13687,6 @@ extern const struct language_data ada_language_data =
0, /* c-style arrays */
1, /* String lower bound */
&ada_varobj_ops,
- ada_is_string_type,
"(...)" /* la_struct_too_deep_ellipsis */
};
@@ -14139,6 +14138,14 @@ public:
ada_print_typedef (type, new_symbol, stream);
}
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ return ada_is_string_type (type);
+ }
+
+
protected:
/* See language.h. */
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index aca0d7a..f29f2ce 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -895,7 +895,6 @@ extern const struct language_data c_language_data =
1, /* c-style arrays */
0, /* String lower bound */
&c_varobj_ops,
- c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
@@ -997,7 +996,6 @@ extern const struct language_data cplus_language_data =
1, /* c-style arrays */
0, /* String lower bound */
&cplus_varobj_ops,
- c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
@@ -1196,7 +1194,6 @@ extern const struct language_data asm_language_data =
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
@@ -1253,7 +1250,6 @@ extern const struct language_data minimal_language_data =
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- c_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index b907dd7..4ebb011 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -148,7 +148,6 @@ extern const struct language_data d_language_data =
1, /* C-style arrays. */
0, /* String lower bound. */
&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 946d5bc..58b41d1 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -291,17 +291,6 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
return nullptr;
}
-/* Return true if TYPE is a string. */
-
-static bool
-f_is_string_type_p (struct type *type)
-{
- type = check_typedef (type);
- return (type->code () == TYPE_CODE_STRING
- || (type->code () == TYPE_CODE_ARRAY
- && TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_CHAR));
-}
-
/* Special expression lengths for Fortran. */
static void
@@ -519,7 +508,6 @@ extern const struct language_data f_language_data =
0, /* arrays are first-class (not c-style) */
1, /* String lower bound */
&default_varobj_ops,
- f_is_string_type_p,
"(...)" /* la_struct_too_deep_ellipsis */
};
@@ -709,6 +697,16 @@ public:
f_print_typedef (type, new_symbol, stream);
}
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ type = check_typedef (type);
+ return (type->code () == TYPE_CODE_STRING
+ || (type->code () == TYPE_CODE_ARRAY
+ && TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_CHAR));
+ }
+
protected:
/* See language.h. */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index fa26399..cb42ef1 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -131,16 +131,6 @@ go_classify_struct_type (struct type *type)
return GO_TYPE_NONE;
}
-/* Return true if TYPE is a string. */
-
-static bool
-go_is_string_type_p (struct type *type)
-{
- type = check_typedef (type);
- return (type->code () == TYPE_CODE_STRUCT
- && go_classify_struct_type (type) == GO_TYPE_STRING);
-}
-
/* Subroutine of unpack_mangled_go_symbol to simplify it.
Given "[foo.]bar.baz", store "bar" in *PACKAGEP and "baz" in *OBJECTP.
We stomp on the last '.' to nul-terminate "bar".
@@ -533,7 +523,6 @@ extern const struct language_data go_language_data =
1, /* C-style arrays. */
0, /* String lower bound. */
&default_varobj_ops,
- go_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
@@ -638,6 +627,16 @@ public:
{
return go_parse (ps);
}
+
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ type = check_typedef (type);
+ return (type->code () == TYPE_CODE_STRUCT
+ && go_classify_struct_type (type) == GO_TYPE_STRING);
+ }
+
};
/* Single instance of the Go language class. */
diff --git a/gdb/language.c b/gdb/language.c
index 5ae8c46..c993cfc 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -690,6 +690,14 @@ language_defn::print_typedef (struct type *type, struct symbol *new_symbol,
c_print_typedef (type, new_symbol, stream);
}
+/* See language.h. */
+
+bool
+language_defn::is_string_type_p (struct type *type) const
+{
+ return c_is_string_type_p (type);
+}
+
/* The default implementation of the get_symbol_name_matcher_inner method
from the language_defn class. Matches with strncmp_iw. */
@@ -741,9 +749,10 @@ language_defn::get_symbol_name_matcher_inner
return default_symbol_name_matcher;
}
-/* See language.h. */
+/* Return true if TYPE is a string type, otherwise return false. This
+ default implementation only detects TYPE_CODE_STRING. */
-bool
+static bool
default_is_string_type_p (struct type *type)
{
type = check_typedef (type);
@@ -789,7 +798,6 @@ extern const struct language_data unknown_language_data =
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- default_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
@@ -884,6 +892,13 @@ public:
{
error (_("unimplemented unknown_language::print_typedef called"));
}
+
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ return default_is_string_type_p (type);
+ }
};
/* Single instance of the unknown language class. */
@@ -909,7 +924,6 @@ extern const struct language_data auto_language_data =
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- default_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
@@ -1004,6 +1018,13 @@ public:
{
error (_("unimplemented auto_language::print_typedef called"));
}
+
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ return default_is_string_type_p (type);
+ }
};
/* Single instance of the fake "auto" language. */
diff --git a/gdb/language.h b/gdb/language.h
index 19cd820..d2e5b73 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -267,9 +267,6 @@ struct language_data
/* Various operations on varobj. */
const struct lang_varobj_ops *la_varobj_ops;
- /* Return true if TYPE is a string type. */
- bool (*la_is_string_type_p) (struct type *type);
-
/* This string is used by the 'set print max-depth' setting. When GDB
replaces a struct or union (during value printing) that is "too
deep" this string is displayed instead. */
@@ -553,6 +550,9 @@ struct language_defn : language_data
virtual void print_typedef (struct type *type, struct symbol *new_symbol,
struct ui_file *stream) const;
+ /* Return true if TYPE is a string type. */
+ virtual bool is_string_type_p (struct type *type) const;
+
protected:
/* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
@@ -684,10 +684,6 @@ extern enum language set_language (enum language);
extern int pointer_type (struct type *);
-/* Return true if TYPE is a string type, otherwise return false. This
- default implementation only detects TYPE_CODE_STRING. */
-extern bool default_is_string_type_p (struct type *type);
-
/* Error messages */
extern void range_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index f0f7c22..2c39359 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -42,27 +42,6 @@ m2_printchar (int c, struct type *type, struct ui_file *stream)
fputs_filtered ("'", stream);
}
-/* Return true if TYPE is a string. */
-
-static bool
-m2_is_string_type_p (struct type *type)
-{
- type = check_typedef (type);
- if (type->code () == TYPE_CODE_ARRAY
- && TYPE_LENGTH (type) > 0
- && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
- {
- struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
-
- if (TYPE_LENGTH (elttype) == 1
- && (elttype->code () == TYPE_CODE_INT
- || elttype->code () == TYPE_CODE_CHAR))
- return true;
- }
-
- return false;
-}
-
static struct value *
evaluate_subexp_modula2 (struct type *expect_type, struct expression *exp,
int *pos, enum noside noside)
@@ -235,7 +214,6 @@ extern const struct language_data m2_language_data =
0, /* arrays are first-class (not c-style) */
0, /* String lower bound */
&default_varobj_ops,
- m2_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
@@ -435,6 +413,25 @@ public:
m2_print_typedef (type, new_symbol, stream);
}
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ type = check_typedef (type);
+ if (type->code () == TYPE_CODE_ARRAY
+ && TYPE_LENGTH (type) > 0
+ && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
+ {
+ struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
+
+ if (TYPE_LENGTH (elttype) == 1
+ && (elttype->code () == TYPE_CODE_INT
+ || elttype->code () == TYPE_CODE_CHAR))
+ return true;
+ }
+
+ return false;
+ }
};
/* Single instance of the M2 language. */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 0c95273..63cdac1 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -343,7 +343,6 @@ extern const struct language_data objc_language_data =
1, /* C-style arrays */
0, /* String lower bound */
&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 2431fae..eccf1df 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1022,7 +1022,6 @@ extern const struct language_data opencl_language_data =
1, /* c-style arrays */
0, /* String lower bound */
&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 9fd8231..07afbdd 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -152,16 +152,6 @@ is_pascal_string_type (struct type *type,int *length_pos,
return 0;
}
-/* This is a wrapper around IS_PASCAL_STRING_TYPE that returns true if TYPE
- is a string. */
-
-static bool
-pascal_is_string_type_p (struct type *type)
-{
- return is_pascal_string_type (type, nullptr, nullptr, nullptr,
- nullptr, nullptr) > 0;
-}
-
static void pascal_one_char (int, struct ui_file *, int *);
/* Print the character C on STREAM as part of the contents of a literal
@@ -282,7 +272,6 @@ extern const struct language_data pascal_language_data =
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- pascal_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
@@ -502,6 +491,13 @@ public:
pascal_print_typedef (type, new_symbol, stream);
}
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ return is_pascal_string_type (type, nullptr, nullptr, nullptr,
+ nullptr, nullptr) > 0;
+ }
};
/* Single instance of the Pascal language class. */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 083b3f7..d1efea1 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -226,26 +226,6 @@ rust_chartype_p (struct type *type)
&& TYPE_UNSIGNED (type));
}
-/* Return true if TYPE is a string type. */
-
-static bool
-rust_is_string_type_p (struct type *type)
-{
- LONGEST low_bound, high_bound;
-
- type = check_typedef (type);
- return ((type->code () == TYPE_CODE_STRING)
- || (type->code () == TYPE_CODE_PTR
- && (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_ARRAY
- && rust_u8_type_p (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type)))
- && get_array_bounds (TYPE_TARGET_TYPE (type), &low_bound,
- &high_bound)))
- || (type->code () == TYPE_CODE_STRUCT
- && !rust_enum_p (type)
- && rust_slice_type_p (type)
- && strcmp (type->name (), "&str") == 0));
-}
-
/* If VALUE represents a trait object pointer, return the underlying
pointer with the correct (i.e., runtime) type. Otherwise, return
NULL. */
@@ -1946,7 +1926,6 @@ extern const struct language_data rust_language_data =
1, /* c-style arrays */
0, /* String lower bound */
&default_varobj_ops,
- rust_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
@@ -2152,6 +2131,25 @@ public:
type_print (type, "", stream, 0);
fprintf_filtered (stream, ";");
}
+
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ LONGEST low_bound, high_bound;
+
+ type = check_typedef (type);
+ return ((type->code () == TYPE_CODE_STRING)
+ || (type->code () == TYPE_CODE_PTR
+ && (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_ARRAY
+ && rust_u8_type_p (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type)))
+ && get_array_bounds (TYPE_TARGET_TYPE (type), &low_bound,
+ &high_bound)))
+ || (type->code () == TYPE_CODE_STRUCT
+ && !rust_enum_p (type)
+ && rust_slice_type_p (type)
+ && strcmp (type->name (), "&str") == 0));
+ }
};
/* Single instance of the Rust language class. */
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 51c77c3..db98ca2 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -298,7 +298,7 @@ val_print_scalar_or_string_type_p (struct type *type,
const struct language_defn *language)
{
return (val_print_scalar_type_p (type)
- || language->la_is_string_type_p (type));
+ || language->is_string_type_p (type));
}
/* See its definition in value.h. */