Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: drow@false.org
Cc: gdb-patches@sourceware.org
Subject: Re: [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral       types for internal variables
Date: Tue, 02 Sep 2008 23:53:00 -0000	[thread overview]
Message-ID: <200809022352.m82Nq4UG014613@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <200809022154.m82LsF4v015969@d12av02.megacenter.de.ibm.com> from "Ulrich Weigand" at Sep 02, 2008 11:54:15 PM

> Daniel Jacobowitz wrote:
> > On Sun, Aug 31, 2008 at 07:51:08PM +0200, Ulrich Weigand wrote:
> > > One problem is the $_ variable, which holds a pointer value.  To
> > > allow using a platform-neutral type for this, I'm introducing a
> > > new platform-neutral pointer type builtin_type_void_ptr.  The
> > > lenght of this type is chosen so that it can hold every CORE_ADDR
> > > value.
> > 
> > I don't think this is a good idea.  Target-specific code should not be
> > required to correctly handle jumbo pointers, e.g. in "(gdb) print
> > foo ($_)".  In a command function, we must already have some idea of
> > what the associated architecture is (e.g. to initialize the
> > architecture used by the expression evaluator); why not use that?
> 
> I guess that would mean current_gdbarch for now.

Like below.  Once we eliminate current_gdbarch in command functions,
those new instances introduces below can go away again ...

Bye,
Ulrich

ChangeLog:

	* defs.h (struct gdbarch): Add forward declaration.
	(set_next_address): Add GDBARCH argument.
	* printcmd.c (set_next_address): Use it to find pointer type.
	* breakpoint.c (breakpoint_1): Update call.
	* source.c (line_info): Likewise.
	* findcmd.c (find_command): Use current_gdbarch to find pointer type.

	* breakpoint.c (set_breakpoint_count): Use platform-neutral
	types for internal variable values.
	* infrun.c (handle_inferior_event): Likewise.
	* source.c (forward_search_command, reverse_search_command): Likewise.
	* tracepoint.c (set_tracepoint_count, set_traceframe_num,
	set_tracepoint_num, set_traceframe_context): Likewise.


Index: gdb-head/gdb/breakpoint.c
===================================================================
--- gdb-head.orig/gdb/breakpoint.c
+++ gdb-head/gdb/breakpoint.c
@@ -401,7 +401,7 @@ set_breakpoint_count (int num)
 {
   breakpoint_count = num;
   set_internalvar (lookup_internalvar ("bpnum"),
-		   value_from_longest (builtin_type_int, (LONGEST) num));
+		   value_from_longest (builtin_type_int32, (LONGEST) num));
 }
 
 /* Used in run_command to zero the hit count when a new run starts. */
@@ -4017,7 +4017,7 @@ breakpoint_1 (int bnum, int allflag)
       /* Compare against (CORE_ADDR)-1 in case some compiler decides
 	 that a comparison of an unsigned with -1 is always false.  */
       if (last_addr != (CORE_ADDR) -1 && !server_command)
-	set_next_address (last_addr);
+	set_next_address (current_gdbarch, last_addr);
     }
 
   /* FIXME? Should this be moved up so that it is only called when
Index: gdb-head/gdb/findcmd.c
===================================================================
--- gdb-head.orig/gdb/findcmd.c
+++ gdb-head/gdb/findcmd.c
@@ -292,13 +292,14 @@ find_command (char *args, int from_tty)
   /* Record and print the results.  */
 
   set_internalvar (lookup_internalvar ("numfound"),
-		   value_from_longest (builtin_type_int,
+		   value_from_longest (builtin_type_int32,
 				       (LONGEST) found_count));
   if (found_count > 0)
     {
+      struct gdbarch *gdbarch = current_gdbarch;
+      struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
       set_internalvar (lookup_internalvar ("_"),
-		       value_from_pointer (builtin_type_void_data_ptr,
-					   last_found_addr));
+		       value_from_pointer (ptr_type, last_found_addr));
     }
 
   if (found_count == 0)
Index: gdb-head/gdb/infrun.c
===================================================================
--- gdb-head.orig/gdb/infrun.c
+++ gdb-head/gdb/infrun.c
@@ -2017,7 +2017,7 @@ handle_inferior_event (struct execution_
       /* Record the exit code in the convenience variable $_exitcode, so
          that the user can inspect this again later.  */
       set_internalvar (lookup_internalvar ("_exitcode"),
-		       value_from_longest (builtin_type_int,
+		       value_from_longest (builtin_type_int32,
 					   (LONGEST) ecs->ws.value.integer));
       gdb_flush (gdb_stdout);
       target_mourn_inferior ();
Index: gdb-head/gdb/printcmd.c
===================================================================
--- gdb-head.orig/gdb/printcmd.c
+++ gdb-head/gdb/printcmd.c
@@ -503,13 +503,15 @@ print_scalar_formatted (const void *vala
    The `info lines' command uses this.  */
 
 void
-set_next_address (CORE_ADDR addr)
+set_next_address (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
+  struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+
   next_address = addr;
 
   /* Make address available to the user as $_.  */
   set_internalvar (lookup_internalvar ("_"),
-		   value_from_pointer (builtin_type_void_data_ptr, addr));
+		   value_from_pointer (ptr_type, addr));
 }
 
 /* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
Index: gdb-head/gdb/source.c
===================================================================
--- gdb-head.orig/gdb/source.c
+++ gdb-head/gdb/source.c
@@ -1511,7 +1511,7 @@ line_info (char *arg, int from_tty)
 	    }
 
 	  /* x/i should display this line's code.  */
-	  set_next_address (start_pc);
+	  set_next_address (current_gdbarch, start_pc);
 
 	  /* Repeating "info line" should do the following line.  */
 	  last_line_listed = sal.line + 1;
@@ -1614,7 +1614,7 @@ forward_search_command (char *regex, int
 	  fclose (stream);
 	  print_source_lines (current_source_symtab, line, line + 1, 0);
 	  set_internalvar (lookup_internalvar ("_"),
-			   value_from_longest (builtin_type_int,
+			   value_from_longest (builtin_type_int32,
 					       (LONGEST) line));
 	  current_source_line = max (line - lines_to_list / 2, 1);
 	  return;
@@ -1696,7 +1696,7 @@ reverse_search_command (char *regex, int
 	  fclose (stream);
 	  print_source_lines (current_source_symtab, line, line + 1, 0);
 	  set_internalvar (lookup_internalvar ("_"),
-			   value_from_longest (builtin_type_int,
+			   value_from_longest (builtin_type_int32,
 					       (LONGEST) line));
 	  current_source_line = max (line - lines_to_list / 2, 1);
 	  return;
Index: gdb-head/gdb/tracepoint.c
===================================================================
--- gdb-head.orig/gdb/tracepoint.c
+++ gdb-head/gdb/tracepoint.c
@@ -220,7 +220,7 @@ set_tracepoint_count (int num)
 {
   tracepoint_count = num;
   set_internalvar (lookup_internalvar ("tpnum"),
-		   value_from_longest (builtin_type_int, (LONGEST) num));
+		   value_from_longest (builtin_type_int32, (LONGEST) num));
 }
 
 /* Set traceframe number to NUM.  */
@@ -229,7 +229,7 @@ set_traceframe_num (int num)
 {
   traceframe_number = num;
   set_internalvar (lookup_internalvar ("trace_frame"),
-		   value_from_longest (builtin_type_int, (LONGEST) num));
+		   value_from_longest (builtin_type_int32, (LONGEST) num));
 }
 
 /* Set tracepoint number to NUM.  */
@@ -238,8 +238,7 @@ set_tracepoint_num (int num)
 {
   tracepoint_number = num;
   set_internalvar (lookup_internalvar ("tracepoint"),
-		   value_from_longest (builtin_type_int, 
-				       (LONGEST) num));
+		   value_from_longest (builtin_type_int32, (LONGEST) num));
 }
 
 /* Set externally visible debug variables for querying/printing
@@ -252,23 +251,19 @@ set_traceframe_context (CORE_ADDR trace_
   static struct type *func_range, *file_range;
   struct value *func_val;
   struct value *file_val;
-  static struct type *charstar;
   int len;
 
-  if (charstar == (struct type *) NULL)
-    charstar = lookup_pointer_type (builtin_type_char);
-
   if (trace_pc == -1)		/* Cease debugging any trace buffers.  */
     {
       traceframe_fun = 0;
       traceframe_sal.pc = traceframe_sal.line = 0;
       traceframe_sal.symtab = NULL;
       set_internalvar (lookup_internalvar ("trace_func"),
-		       value_from_pointer (charstar, (LONGEST) 0));
+		       allocate_value (builtin_type_void));
       set_internalvar (lookup_internalvar ("trace_file"),
-		       value_from_pointer (charstar, (LONGEST) 0));
+		       allocate_value (builtin_type_void));
       set_internalvar (lookup_internalvar ("trace_line"),
-		       value_from_longest (builtin_type_int, 
+		       value_from_longest (builtin_type_int32,
 					   (LONGEST) - 1));
       return;
     }
@@ -280,7 +275,7 @@ set_traceframe_context (CORE_ADDR trace_
   /* Save linenumber as "$trace_line", a debugger variable visible to
      users.  */
   set_internalvar (lookup_internalvar ("trace_line"),
-		   value_from_longest (builtin_type_int,
+		   value_from_longest (builtin_type_int32,
 				       (LONGEST) traceframe_sal.line));
 
   /* Save func name as "$trace_func", a debugger variable visible to
@@ -288,14 +283,14 @@ set_traceframe_context (CORE_ADDR trace_
   if (traceframe_fun == NULL ||
       SYMBOL_LINKAGE_NAME (traceframe_fun) == NULL)
     set_internalvar (lookup_internalvar ("trace_func"),
-		     value_from_pointer (charstar, (LONGEST) 0));
+		     allocate_value (builtin_type_void));
   else
     {
       len = strlen (SYMBOL_LINKAGE_NAME (traceframe_fun));
       func_range = create_range_type (func_range,
-				      builtin_type_int, 0, len - 1);
+				      builtin_type_int32, 0, len - 1);
       func_string = create_array_type (func_string,
-				       builtin_type_char, func_range);
+				       builtin_type_true_char, func_range);
       func_val = allocate_value (func_string);
       deprecated_set_value_type (func_val, func_string);
       memcpy (value_contents_raw (func_val),
@@ -310,14 +305,14 @@ set_traceframe_context (CORE_ADDR trace_
   if (traceframe_sal.symtab == NULL ||
       traceframe_sal.symtab->filename == NULL)
     set_internalvar (lookup_internalvar ("trace_file"),
-		     value_from_pointer (charstar, (LONGEST) 0));
+		     allocate_value (builtin_type_void));
   else
     {
       len = strlen (traceframe_sal.symtab->filename);
       file_range = create_range_type (file_range,
-				      builtin_type_int, 0, len - 1);
+				      builtin_type_int32, 0, len - 1);
       file_string = create_array_type (file_string,
-				       builtin_type_char, file_range);
+				       builtin_type_true_char, file_range);
       file_val = allocate_value (file_string);
       deprecated_set_value_type (file_val, file_string);
       memcpy (value_contents_raw (file_val),
Index: gdb-head/gdb/defs.h
===================================================================
--- gdb-head.orig/gdb/defs.h
+++ gdb-head/gdb/defs.h
@@ -298,6 +298,7 @@ struct cleanup
 struct symtab;
 struct breakpoint;
 struct frame_info;
+struct gdbarch;
 
 /* From utils.c */
 
@@ -570,7 +571,7 @@ extern int info_verbose;
 
 /* From printcmd.c */
 
-extern void set_next_address (CORE_ADDR);
+extern void set_next_address (struct gdbarch *, CORE_ADDR);
 
 extern void print_address_symbolic (CORE_ADDR, struct ui_file *, int,
 				    char *);


-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


  parent reply	other threads:[~2008-09-02 23:53 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-31 17:53 [rfc][00/37] Eliminate builtin_type_ macros uweigand
2008-08-31 17:52 ` [rfc][13/37] Eliminate builtin_type_ macros: Update EVAL_SKIP dummy return type uweigand
2008-09-05 22:56   ` Joel Brobecker
2008-09-07 15:40     ` Ulrich Weigand
2008-09-07 15:49       ` Joel Brobecker
2008-08-31 17:52 ` [rfc][15/37] Eliminate builtin_type_ macros: Dereferencing of integer types uweigand
2008-09-01  7:19   ` Tom Tromey
2008-09-02 23:34     ` Ulrich Weigand
2008-09-05 23:02   ` Joel Brobecker
2008-08-31 17:52 ` [rfc][07/37] Eliminate builtin_type_ macros: Use expression arch for size_t type uweigand
2008-09-05 18:18   ` Joel Brobecker
2008-09-05 20:16     ` Ulrich Weigand
2008-08-31 17:52 ` [rfc][09/37] Eliminate builtin_type_ macros: Make argument promotion explicit uweigand
2008-08-31 17:52 ` [rfc][29/37] Eliminate builtin_type_ macros: Update valarith.c routines uweigand
2008-08-31 17:52 ` [rfc][23/37] Eliminate builtin_type_ macros: Platform-neutral types for internal variables uweigand
2008-09-02 12:43   ` Daniel Jacobowitz
2008-09-02 21:55     ` Ulrich Weigand
2008-09-02 22:00       ` Daniel Jacobowitz
2008-09-02 23:53       ` Ulrich Weigand [this message]
2008-08-31 17:52 ` [rfc][21/37] Eliminate builtin_type_ macros: Platform-neutral builtin_type_void uweigand
2008-09-06  0:38   ` Joel Brobecker
2008-09-06  4:12     ` Daniel Jacobowitz
2008-09-06 14:00       ` Joel Brobecker
2008-09-07 15:59       ` Ulrich Weigand
2008-09-13 15:23         ` Daniel Jacobowitz
2008-09-13 17:23         ` Joel Brobecker
2008-08-31 17:52 ` [rfc][05/37] Eliminate builtin_type_ macros: Replace LA_BOOL_TYPE macro uweigand
2008-09-05 18:08   ` Joel Brobecker
2008-08-31 17:52 ` [rfc][19/37] Eliminate builtin_type_ macros: Ada range type handling uweigand
2008-09-06  0:24   ` Joel Brobecker
2008-09-07 15:43     ` Ulrich Weigand
2008-09-09 18:00       ` Joel Brobecker
2008-09-09 20:21         ` Ulrich Weigand
2008-09-09 22:08           ` Joel Brobecker
2008-09-09 22:32             ` Ulrich Weigand
2008-09-10  6:09               ` Joel Brobecker
2008-09-10  9:51                 ` Ulrich Weigand
2008-08-31 17:52 ` [rfc][26/37] Eliminate builtin_type_ macros: Use per-frame architecture uweigand
2008-08-31 17:52 ` [rfc][32/37] Eliminate builtin_type_ macros: Update value-printing code uweigand
2008-08-31 17:52 ` [rfc][30/37] Eliminate builtin_type_ macros: Remove gdbarch_name_of_malloc uweigand
2008-08-31 17:52 ` [rfc][16/37] Eliminate builtin_type_ macros: Ada fixed/double conversions uweigand
2008-09-05 23:13   ` Joel Brobecker
2008-08-31 17:52 ` [rfc][24/37] Eliminate builtin_type_ macros: Platform-neutral generic integers uweigand
2008-09-06  3:15   ` Joel Brobecker
2008-09-07 16:44     ` Ulrich Weigand
2008-08-31 17:52 ` [rfc][02/37] Eliminate builtin_type_ macros: Introduce expression architecture uweigand
2008-08-31 17:52 ` [rfc][11/37] Eliminate builtin_type_ macros: Update ax-gdb expression evaluator uweigand
2008-08-31 17:52 ` [rfc][33/37] Eliminate builtin_type_ macros: Default target word size uweigand
2008-08-31 17:52 ` [rfc][01/37] Eliminate builtin_type_ macros: Unused write_exp_msymbol parameters uweigand
2008-08-31 17:53 ` [rfc][22/37] Eliminate builtin_type_ macros: Platform-neutral "true char" types uweigand
2008-08-31 17:53 ` [rfc][36/37] Eliminate builtin_type_ macros: Use target arch in solib code uweigand
2008-08-31 17:53 ` [rfc][12/37] Eliminate builtin_type_ macros: Remove redundant coerce_enum/coerce_number uweigand
2008-08-31 17:53 ` [rfc][17/37] Eliminate builtin_type_ macros: Ada pos_atr result type uweigand
2008-08-31 17:53 ` [rfc][08/37] Eliminate builtin_type_ macros: Make pointer arithmetic explicit uweigand
2008-09-02 12:38   ` Daniel Jacobowitz
2008-09-02 21:48     ` Ulrich Weigand
2008-09-02 21:52       ` Daniel Jacobowitz
2008-09-04 22:32       ` Tom Tromey
2008-09-05 18:21         ` Joel Brobecker
2008-08-31 17:53 ` [rfc][04/37] Eliminate builtin_type_ macros: Introduce java_language_arch_info uweigand
2008-08-31 17:53 ` [rfc][35/37] Eliminate builtin_type_ macros: Use target arch in bsd-uthread.c uweigand
2008-08-31 17:53 ` [rfc][20/37] Eliminate builtin_type_ macros: Objective-C expression evaluation uweigand
2008-08-31 17:53 ` [rfc][37/37] Eliminate builtin_type_ macros: Delete the macros uweigand
2008-08-31 17:53 ` [rfc][06/37] Eliminate builtin_type_ macros: Make OP_COMPLEX type explicit uweigand
2008-08-31 17:53 ` [rfc][27/37] Eliminate builtin_type_ macros: Update C++ ABI handling uweigand
2008-09-05 20:18   ` Ulrich Weigand
2008-08-31 17:53 ` [rfc][10/37] Eliminate builtin_type_ macros: Use expression arch for argument promotion uweigand
2008-09-05 22:39   ` Joel Brobecker
2008-08-31 17:53 ` [rfc][18/37] Eliminate builtin_type_ macros: Ada System.Address special handling uweigand
2008-08-31 17:53 ` [rfc][03/37] Eliminate builtin_type_ macros: Extract bitstring subscript handling uweigand
2008-09-05 18:16   ` Joel Brobecker
2008-09-05 20:17     ` Ulrich Weigand
2008-08-31 17:53 ` [rfc][14/37] Eliminate builtin_type_ macros: Implicit dereferencing of references uweigand
2008-08-31 18:12 ` [rfc][34/37] Eliminate builtin_type_ macros: Use target arch in procfs.c uweigand
2008-08-31 18:13 ` [rfc][31/37] Eliminate builtin_type_ macros: Inferior call argument types uweigand
2008-09-06  1:37   ` Joel Brobecker
2008-08-31 18:15 ` [rfc][28/37] Eliminate builtin_type_ macros: Update infcall.c routines uweigand
2008-09-02 12:48   ` Daniel Jacobowitz
2008-09-02 21:56     ` Ulrich Weigand
2008-08-31 18:16 ` [rfc][25/37] Eliminate builtin_type_ macros: Update *-tdep.c files uweigand
2008-08-31 22:20 ` [rfc][00/37] Eliminate builtin_type_ macros Mark Kettenis
2008-09-01  3:46   ` David Miller
2008-09-01 18:57   ` Ulrich Weigand
2008-09-02 10:22     ` Mark Kettenis
2008-09-02 12:30       ` Daniel Jacobowitz
2008-09-02 21:37       ` Ulrich Weigand
2008-09-02 12:50 ` Daniel Jacobowitz
2008-09-02 22:02   ` Ulrich Weigand
2008-09-02 22:12     ` Daniel Jacobowitz
2008-09-06  3:16 ` Joel Brobecker
2008-09-07 16:43   ` Ulrich Weigand
2008-09-09 18:05     ` Joel Brobecker
2008-09-09 20:21       ` Ulrich Weigand
2008-09-09 21:18       ` Joel Brobecker
2008-09-09 22:12         ` Ulrich Weigand
2008-09-10  6:18           ` Joel Brobecker
2008-09-10  9:43             ` Ulrich Weigand
2008-09-10 16:25               ` Joel Brobecker

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=200809022352.m82Nq4UG014613@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=drow@false.org \
    --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