]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Let phex and phex_nz handle sizeof_l==1
authorTom Tromey <tromey@adacore.com>
Thu, 3 Feb 2022 20:18:25 +0000 (13:18 -0700)
committerTom Tromey <tromey@adacore.com>
Mon, 7 Mar 2022 14:52:59 +0000 (07:52 -0700)
Currently, neither phex nor phex_nz handle sizeof_l==1 -- they let
this case fall through to the default case.  However, a subsequent
patch in this series needs this case to work correctly.

I looked at all calls to these functions that pass a 1 for the
sizeof_l parameter.  The only such case seems to be correct with this
change.

gdbsupport/print-utils.cc

index 0ef8cb829a13b4f33bb6ec47baf8a78e19b6fb84..73ff1afda30abdda5e9e53923271ca18386cecdd 100644 (file)
@@ -168,6 +168,10 @@ phex (ULONGEST l, int sizeof_l)
       str = get_print_cell ();
       xsnprintf (str, PRINT_CELL_SIZE, "%04x", (unsigned short) (l & 0xffff));
       break;
+    case 1:
+      str = get_print_cell ();
+      xsnprintf (str, PRINT_CELL_SIZE, "%02x", (unsigned short) (l & 0xff));
+      break;
     default:
       str = phex (l, sizeof (l));
       break;
@@ -206,6 +210,10 @@ phex_nz (ULONGEST l, int sizeof_l)
       str = get_print_cell ();
       xsnprintf (str, PRINT_CELL_SIZE, "%x", (unsigned short) (l & 0xffff));
       break;
+    case 1:
+      str = get_print_cell ();
+      xsnprintf (str, PRINT_CELL_SIZE, "%x", (unsigned short) (l & 0xff));
+      break;
     default:
       str = phex_nz (l, sizeof (l));
       break;