]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove some uses of LA_PRINT_STRING
authorAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 19 Nov 2020 17:52:00 +0000 (17:52 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 23 Dec 2020 20:53:14 +0000 (20:53 +0000)
This commit removes some, but not all, uses of LA_PRINT_STRING.  In
this commit I've removed those uses where there is an obvious language
object on which I can instead call the printstr method.

In the remaining 3 uses it is harder to know if the correct thing is
to call printstr on the current language, or on a specific language.
Currently obviously, we always call on the current language (as that's
what LA_PRINT_STRING does), and clearly this behaviour is good enough
right now, but is it "right"?  I've left them for now and will give
them more thought in the future.

gdb/ChangeLog:

* expprint.c (print_subexp_standard): Replace uses of
LA_PRINT_STRING.
* f-valprint.c (f_language::value_print_inner): Likewise.
* guile/scm-pretty-print.c (ppscm_print_string_repr): Likewise.
* p-valprint.c (pascal_language::value_print_inner): Likewise.
* python/py-prettyprint.c (print_string_repr): Likewise.

gdb/ChangeLog
gdb/expprint.c
gdb/f-valprint.c
gdb/guile/scm-pretty-print.c
gdb/p-valprint.c
gdb/python/py-prettyprint.c

index a7224352c3243d71441937edef9e3a73a606fe98..26d7f5837ccadb50afc37c7ab5c8b32f7e485450 100644 (file)
@@ -1,3 +1,12 @@
+2020-12-23  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * expprint.c (print_subexp_standard): Replace uses of
+       LA_PRINT_STRING.
+       * f-valprint.c (f_language::value_print_inner): Likewise.
+       * guile/scm-pretty-print.c (ppscm_print_string_repr): Likewise.
+       * p-valprint.c (pascal_language::value_print_inner): Likewise.
+       * python/py-prettyprint.c (print_string_repr): Likewise.
+
 2020-12-23  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * rust-exp.y (rust_parse): Rename to...
index 5b4ea14d440b955d29e670f4a70567d172f5ee0d..51dbc567a90a9eff71c8d13af89afab5fb19665a 100644 (file)
@@ -226,9 +226,10 @@ print_subexp_standard (struct expression *exp, int *pos,
           If necessary, we can temporarily set it to zero, or pass it as an
           additional parameter to LA_PRINT_STRING.  -fnf */
        get_user_print_options (&opts);
-       LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
-                        (gdb_byte *) &exp->elts[pc + 2].string, nargs,
-                        NULL, 0, &opts);
+       exp->language_defn
+         ->printstr (stream, builtin_type (exp->gdbarch)->builtin_char,
+                     (gdb_byte *) &exp->elts[pc + 2].string, nargs,
+                     NULL, 0, &opts);
       }
       return;
 
@@ -241,9 +242,10 @@ print_subexp_standard (struct expression *exp, int *pos,
        (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
        fputs_filtered ("@\"", stream);
        get_user_print_options (&opts);
-       LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
-                        (gdb_byte *) &exp->elts[pc + 2].string, nargs,
-                        NULL, 0, &opts);
+       exp->language_defn
+         ->printstr (stream, builtin_type (exp->gdbarch)->builtin_char,
+                     (gdb_byte *) &exp->elts[pc + 2].string, nargs,
+                     NULL, 0, &opts);
        fputs_filtered ("\"", stream);
       }
       return;
@@ -325,8 +327,9 @@ print_subexp_standard (struct expression *exp, int *pos,
          struct value_print_options opts;
 
          get_user_print_options (&opts);
-         LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
-                          (gdb_byte *) tempstr, nargs - 1, NULL, 0, &opts);
+         exp->language_defn
+           ->printstr (stream, builtin_type (exp->gdbarch)->builtin_char,
+                       (gdb_byte *) tempstr, nargs - 1, NULL, 0, &opts);
          (*pos) = pc;
        }
       else
index d147caa36fc94b0ad587ba84d752d1e94dafad52..63cd9b3bd6b0227f00a4eb8b42dc86235c7c68ee 100644 (file)
@@ -235,8 +235,8 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
     {
     case TYPE_CODE_STRING:
       f77_get_dynamic_length_of_aggregate (type);
-      LA_PRINT_STRING (stream, builtin_type (gdbarch)->builtin_char,
-                      valaddr, TYPE_LENGTH (type), NULL, 0, options);
+      printstr (stream, builtin_type (gdbarch)->builtin_char, valaddr,
+               TYPE_LENGTH (type), NULL, 0, options);
       break;
 
     case TYPE_CODE_ARRAY:
@@ -247,9 +247,9 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
          struct type *ch_type = TYPE_TARGET_TYPE (type);
 
          f77_get_dynamic_length_of_aggregate (type);
-         LA_PRINT_STRING (stream, ch_type, valaddr,
-                          TYPE_LENGTH (type) / TYPE_LENGTH (ch_type),
-                          NULL, 0, options);
+         printstr (stream, ch_type, valaddr,
+                   TYPE_LENGTH (type) / TYPE_LENGTH (ch_type), NULL, 0,
+                   options);
        }
       break;
 
index 0bbcc4de57981e48ddfc62df7dbea547bb83f321..e08202cbb58a7c5edfea22c4daaf20087273bcb2 100644 (file)
@@ -675,8 +675,8 @@ ppscm_print_string_repr (SCM printer, enum display_hint hint,
        {
          struct type *type = builtin_type (gdbarch)->builtin_char;
          
-         LA_PRINT_STRING (stream, type, (gdb_byte *) string.get (),
-                          length, NULL, 0, options);
+         language->printstr (stream, type, (gdb_byte *) string.get (),
+                             length, NULL, 0, options);
        }
       else
        {
index b748c066fb0990d82a1c80d94589674b57142d12..323b7c3aa26767d2a285437fb0b6228def04bb89 100644 (file)
@@ -116,8 +116,8 @@ pascal_language::value_print_inner (struct value *val,
                    len = temp_len;
                  }
 
-               LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
-                                valaddr, len, NULL, 0, options);
+               printstr (stream, TYPE_TARGET_TYPE (type), valaddr, len,
+                         NULL, 0, options);
                i = len;
              }
            else
@@ -318,8 +318,8 @@ pascal_language::value_print_inner (struct value *val,
            {
              len = extract_unsigned_integer (valaddr + length_pos,
                                              length_size, byte_order);
-             LA_PRINT_STRING (stream, char_type, valaddr + string_pos,
-                              len, NULL, 0, options);
+             printstr (stream, char_type, valaddr + string_pos, len,
+                       NULL, 0, options);
            }
          else
            pascal_object_print_value_fields (val, stream, recurse,
index 8eaa41fb187c7ef9fad2f2fe2b0ed21dc2b18db0..6300cb0bc5732b1cc09afb661bbe4724bafa62ee 100644 (file)
@@ -318,8 +318,8 @@ print_string_repr (PyObject *printer, const char *hint,
              type = builtin_type (gdbarch)->builtin_char;
 
              if (hint && !strcmp (hint, "string"))
-               LA_PRINT_STRING (stream, type, (gdb_byte *) output,
-                                length, NULL, 0, options);
+               language->printstr (stream, type, (gdb_byte *) output,
+                                   length, NULL, 0, options);
              else
                fputs_filtered (output, stream);
            }