This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] ping/FYI: [patch] Require long long for GDB


On Wed, 05 Dec 2012 18:44:41 +0100, Tom Tromey wrote:
> I was grepping and noticed extract_cu_value has
> 
>   if (sizeof (ULONGEST) < 8)
> 
> Surely that is never taken now and could be replaced with a static
> assert.

That was a nice code simplification, thanks.

I grepped other cases but I haven't found another such clear case.

Checked in.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2012-12/msg00040.html

--- src/gdb/ChangeLog	2012/12/09 17:35:39	1.14893
+++ src/gdb/ChangeLog	2012/12/09 18:39:57	1.14894
@@ -1,5 +1,25 @@
 2012-12-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	* configure.ac (CC_HAS_LONG_LONG): Replace by AC_MSG_ERROR.
+	* defs.h (LONGEST, ULONGEST): Remove conditionalization for
+	CC_HAS_LONG_LONG.
+	* dwarf2-frame.c (DW64_CIE_ID): Likewise.
+	* dwarf2read.c (extract_cu_value): Remove the function.
+	(create_cus_from_index_list): Make the return type void, inline the
+	extract_cu_value caller, include new gdb_static_assert.
+	(create_cus_from_index): Make the return type void, update the function
+	comment, update the create_cus_from_index_list caller.
+	(create_signatured_type_table_from_index): Make the return type void,
+	inline the extract_cu_value caller, include new gdb_static_assert.
+	(dwarf2_read_index): Update the create_cus_from_index and
+	create_signatured_type_table_from_index caller.
+	* printcmd.c (ui_printf): Remove conditionalizations for
+	CC_HAS_LONG_LONG.
+	* config.in: Regenerate.
+	* configure: Regenerate.
+
+2012-12-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	* dwarf2read.c (struct dwarf2_cu): New field producer_is_gcc_lt_4_3.
 	Update the comment for checked_producer.
 	(check_producer): New forward declaration.
--- src/gdb/doc/ChangeLog	2012/11/29 17:49:20	1.1389
+++ src/gdb/doc/ChangeLog	2012/12/09 18:39:59	1.1390
@@ -1,3 +1,7 @@
+2012-12-09  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* gdbint.texinfo (Host Definition): Remove CC_HAS_LONG_LONG.
+
 2012-11-29  Tom Tromey  <tromey@redhat.com>
 
 	* gdb.texinfo (SVR4 Process Information): Document missing
--- src/gdb/config.in	2012/11/28 16:21:56	1.150
+++ src/gdb/config.in	2012/12/09 18:39:58	1.151
@@ -12,9 +12,6 @@
 /* Directory of programs. */
 #undef BINDIR
 
-/* Define to 1 if the compiler supports long long. */
-#undef CC_HAS_LONG_LONG
-
 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
    systems. This function is required for `alloca.c' support on those systems.
    */
--- src/gdb/configure	2012/11/28 16:21:56	1.379
+++ src/gdb/configure	2012/12/09 18:39:58	1.380
@@ -11602,10 +11602,9 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_c_long_long" >&5
 $as_echo "$gdb_cv_c_long_long" >&6; }
-if test $gdb_cv_c_long_long = yes; then
-
-$as_echo "#define CC_HAS_LONG_LONG 1" >>confdefs.h
-
+if test $gdb_cv_c_long_long != yes; then
+  # libdecnumber requires long long.
+  as_fn_error "Compiler must support long long for GDB." "$LINENO" 5
 fi
 
 # Check if the compiler and runtime support printing long longs.
--- src/gdb/configure.ac	2012/11/28 16:21:58	1.190
+++ src/gdb/configure.ac	2012/12/09 18:39:59	1.191
@@ -1556,9 +1556,9 @@
 [[switch (foo & 2) { case 0: return 1; }]])],
                                   gdb_cv_c_long_long=yes,
                                   gdb_cv_c_long_long=no)])
-if test $gdb_cv_c_long_long = yes; then
-  AC_DEFINE(CC_HAS_LONG_LONG, 1,
-            [Define to 1 if the compiler supports long long.])
+if test $gdb_cv_c_long_long != yes; then
+  # libdecnumber requires long long.
+  AC_MSG_ERROR([Compiler must support long long for GDB.])
 fi
 
 # Check if the compiler and runtime support printing long longs.
--- src/gdb/defs.h	2012/08/22 20:04:04	1.323
+++ src/gdb/defs.h	2012/12/09 18:39:59	1.324
@@ -125,20 +125,8 @@
 
 #else /* No BFD64 */
 
-#ifdef CC_HAS_LONG_LONG
 #define LONGEST long long
 #define ULONGEST unsigned long long
-#else
-#ifdef BFD_HOST_64_BIT
-/* BFD_HOST_64_BIT is defined for some hosts that don't have long long
-   (e.g. i386-windows) so try it.  */
-#define LONGEST BFD_HOST_64_BIT
-#define ULONGEST BFD_HOST_U_64_BIT
-#else
-#define LONGEST long
-#define ULONGEST unsigned long
-#endif
-#endif
 
 #endif /* No BFD64 */
 
--- src/gdb/dwarf2-frame.c	2012/08/16 15:45:44	1.140
+++ src/gdb/dwarf2-frame.c	2012/12/09 18:39:59	1.141
@@ -1805,11 +1805,7 @@
   fde_table->entries[fde_table->num_entries - 1] = fde;
 }
 
-#ifdef CC_HAS_LONG_LONG
 #define DW64_CIE_ID 0xffffffffffffffffULL
-#else
-#define DW64_CIE_ID ~0
-#endif
 
 /* Defines the type of eh_frames that are expected to be decoded: CIE, FDE
    or any of them.  */
--- src/gdb/dwarf2read.c	2012/12/09 17:35:41	1.716
+++ src/gdb/dwarf2read.c	2012/12/09 18:39:59	1.717
@@ -2356,33 +2356,10 @@
   return dwarf2_per_objfile->all_comp_units[index];
 }
 
-/* A helper function that knows how to read a 64-bit value in a way
-   that doesn't make gdb die.  Returns 1 if the conversion went ok, 0
-   otherwise.  */
-
-static int
-extract_cu_value (const char *bytes, ULONGEST *result)
-{
-  if (sizeof (ULONGEST) < 8)
-    {
-      int i;
-
-      /* Ignore the upper 4 bytes if they are all zero.  */
-      for (i = 0; i < 4; ++i)
-	if (bytes[i + 4] != 0)
-	  return 0;
-
-      *result = extract_unsigned_integer (bytes, 4, BFD_ENDIAN_LITTLE);
-    }
-  else
-    *result = extract_unsigned_integer (bytes, 8, BFD_ENDIAN_LITTLE);
-  return 1;
-}
-
 /* A helper for create_cus_from_index that handles a given list of
    CUs.  */
 
-static int
+static void
 create_cus_from_index_list (struct objfile *objfile,
 			    const gdb_byte *cu_list, offset_type n_elements,
 			    struct dwarf2_section_info *section,
@@ -2396,9 +2373,9 @@
       struct dwarf2_per_cu_data *the_cu;
       ULONGEST offset, length;
 
-      if (!extract_cu_value (cu_list, &offset)
-	  || !extract_cu_value (cu_list + 8, &length))
-	return 0;
+      gdb_static_assert (sizeof (ULONGEST) >= 8);
+      offset = extract_unsigned_integer (cu_list, 8, BFD_ENDIAN_LITTLE);
+      length = extract_unsigned_integer (cu_list + 8, 8, BFD_ENDIAN_LITTLE);
       cu_list += 2 * 8;
 
       the_cu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
@@ -2412,15 +2389,12 @@
       the_cu->is_dwz = is_dwz;
       dwarf2_per_objfile->all_comp_units[base_offset + i / 2] = the_cu;
     }
-
-  return 1;
 }
 
 /* Read the CU list from the mapped index, and use it to create all
-   the CU objects for this objfile.  Return 0 if something went wrong,
-   1 if everything went ok.  */
+   the CU objects for this objfile.  */
 
-static int
+static void
 create_cus_from_index (struct objfile *objfile,
 		       const gdb_byte *cu_list, offset_type cu_list_elements,
 		       const gdb_byte *dwz_list, offset_type dwz_elements)
@@ -2433,21 +2407,20 @@
 		     dwarf2_per_objfile->n_comp_units
 		     * sizeof (struct dwarf2_per_cu_data *));
 
-  if (!create_cus_from_index_list (objfile, cu_list, cu_list_elements,
-				   &dwarf2_per_objfile->info, 0, 0))
-    return 0;
+  create_cus_from_index_list (objfile, cu_list, cu_list_elements,
+			      &dwarf2_per_objfile->info, 0, 0);
 
   if (dwz_elements == 0)
-    return 1;
+    return;
 
   dwz = dwarf2_get_dwz_file ();
-  return create_cus_from_index_list (objfile, dwz_list, dwz_elements,
-				     &dwz->info, 1, cu_list_elements / 2);
+  create_cus_from_index_list (objfile, dwz_list, dwz_elements, &dwz->info, 1,
+			      cu_list_elements / 2);
 }
 
 /* Create the signatured type hash table from the index.  */
 
-static int
+static void
 create_signatured_type_table_from_index (struct objfile *objfile,
 					 struct dwarf2_section_info *section,
 					 const gdb_byte *bytes,
@@ -2470,9 +2443,10 @@
       ULONGEST offset, type_offset_in_tu, signature;
       void **slot;
 
-      if (!extract_cu_value (bytes, &offset)
-	  || !extract_cu_value (bytes + 8, &type_offset_in_tu))
-	return 0;
+      gdb_static_assert (sizeof (ULONGEST) >= 8);
+      offset = extract_unsigned_integer (bytes, 8, BFD_ENDIAN_LITTLE);
+      type_offset_in_tu = extract_unsigned_integer (bytes + 8, 8,
+						    BFD_ENDIAN_LITTLE);
       signature = extract_unsigned_integer (bytes + 16, 8, BFD_ENDIAN_LITTLE);
       bytes += 3 * 8;
 
@@ -2495,8 +2469,6 @@
     }
 
   dwarf2_per_objfile->signatured_types = sig_types_hash;
-
-  return 1;
 }
 
 /* Read the address map data from the mapped index, and use it to
@@ -2793,9 +2765,8 @@
 	}
     }
 
-  if (!create_cus_from_index (objfile, cu_list, cu_list_elements,
-			      dwz_list, dwz_list_elements))
-    return 0;
+  create_cus_from_index (objfile, cu_list, cu_list_elements, dwz_list,
+			 dwz_list_elements);
 
   if (types_list_elements)
     {
@@ -2809,10 +2780,8 @@
       section = VEC_index (dwarf2_section_info_def,
 			   dwarf2_per_objfile->types, 0);
 
-      if (!create_signatured_type_table_from_index (objfile, section,
-						    types_list,
-						    types_list_elements))
-	return 0;
+      create_signatured_type_table_from_index (objfile, section, types_list,
+					       types_list_elements);
     }
 
   create_addrmap_from_index (objfile, &local_map);
--- src/gdb/printcmd.c	2012/12/03 19:59:13	1.214
+++ src/gdb/printcmd.c	2012/12/09 18:39:59	1.215
@@ -2221,7 +2221,7 @@
 	    error (_("long double not supported in printf"));
 #endif
 	  case long_long_arg:
-#if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
+#ifdef PRINTF_HAS_LONG_LONG
 	    {
 	      long long val = value_as_long (val_args[i]);
 
@@ -2356,7 +2356,7 @@
 		 handle %p as glibc would: %#x or a literal "(nil)".  */
 
 	      char *p, *fmt, *fmt_p;
-#if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
+#ifdef PRINTF_HAS_LONG_LONG
 	      long long val = value_as_long (val_args[i]);
 #else
 	      long val = value_as_long (val_args[i]);
@@ -2391,7 +2391,7 @@
 	      gdb_assert (*p == 'p' && *(p + 1) == '\0');
 	      if (val != 0)
 		{
-#if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
+#ifdef PRINTF_HAS_LONG_LONG
 		  *fmt_p++ = 'l';
 #endif
 		  *fmt_p++ = 'l';
--- src/gdb/doc/gdbint.texinfo	2012/09/13 17:35:35	1.342
+++ src/gdb/doc/gdbint.texinfo	2012/12/09 18:39:59	1.343
@@ -2761,11 +2761,6 @@
 @item FOPEN_RB
 Define this if binary files are opened the same way as text files.
 
-@item CC_HAS_LONG_LONG
-@cindex @code{long long} data type
-Define this if the host C compiler supports @code{long long}.  This is set
-by the @code{configure} script.
-
 @item PRINTF_HAS_LONG_LONG
 Define this if the host can handle printing of long long integers via
 the printf format conversion specifier @code{ll}.  This is set by the


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]