GDB: Add support for the new set/show disassembler-options commands.
[deliverable/binutils-gdb.git] / opcodes / disassemble.c
index 1b1524247aeacc968fe7ca1abf85d89ab05be690..eef06584f43cb4cc78776a0282eaab9172317c83 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "sysdep.h"
 #include "dis-asm.h"
+#include "safe-ctype.h"
 
 #ifdef ARCH_all
 #define ARCH_aarch64
@@ -648,8 +649,77 @@ disassemble_init_for_target (struct disassemble_info * info)
 #if defined (ARCH_powerpc) || defined (ARCH_rs6000)
       disassemble_init_powerpc (info);
       break;
+#endif
+#ifdef ARCH_s390
+    case bfd_arch_s390:
+      disassemble_init_s390 (info);
+      break;
 #endif
     default:
       break;
     }
 }
+
+/* Remove whitespace and consecutive commas from OPTIONS.  */
+
+char *
+remove_whitespace_and_extra_commas (char *options)
+{
+  char *str;
+  size_t i, len;
+
+  if (options == NULL)
+    return NULL;
+
+  /* Strip off all trailing whitespace and commas.  */
+  for (len = strlen (options); len > 0; len--)
+    {
+      if (!ISSPACE (options[len - 1]) && options[len - 1] != ',')
+       break;
+      options[len - 1] = '\0';
+    }
+
+  /* Convert all remaining whitespace to commas.  */
+  for (i = 0; options[i] != '\0'; i++)
+    if (ISSPACE (options[i]))
+      options[i] = ',';
+
+  /* Remove consecutive commas.  */
+  for (str = options; *str != '\0'; str++)
+    if (*str == ',' && (*(str + 1) == ',' || str == options))
+      {
+       char *next = str + 1;
+       while (*next == ',')
+         next++;
+       len = strlen (next);
+       if (str != options)
+         str++;
+       memmove (str, next, len);
+       next[len - (size_t)(next - str)] = '\0';
+      }
+  return (strlen (options) != 0) ? options : NULL;
+}
+
+/* Like STRCMP, but treat ',' the same as '\0' so that we match
+   strings like "foobar" against "foobar,xxyyzz,...".  */
+
+int
+disassembler_options_cmp (const char *s1, const char *s2)
+{
+  unsigned char c1, c2;
+
+  do
+    {
+      c1 = (unsigned char) *s1++;
+      if (c1 == ',')
+       c1 = '\0';
+      c2 = (unsigned char) *s2++;
+      if (c2 == ',')
+       c2 = '\0';
+      if (c1 == '\0')
+       return c1 - c2;
+    }
+  while (c1 == c2);
+
+  return c1 - c2;
+}
This page took 0.02911 seconds and 4 git commands to generate.