- SAVED_F77_COMMON_PTR tmp;
-
- tmp = head_common_list;
-
- printf_filtered (_("All COMMON blocks visible at this level:\n\n"));
-
- while (tmp != NULL)
- {
- if (strcmp (tmp->owning_function, funname) == 0)
- printf_filtered ("%s\n", tmp->name);
-
- tmp = tmp->next;
- }
+ struct block_iterator iter;
+ struct symbol *sym;
+ struct value_print_options opts;
+
+ get_user_print_options (&opts);
+
+ ALL_BLOCK_SYMBOLS (block, iter, sym)
+ if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN)
+ {
+ const struct common_block *common = SYMBOL_VALUE_COMMON_BLOCK (sym);
+ size_t index;
+
+ gdb_assert (SYMBOL_CLASS (sym) == LOC_COMMON_BLOCK);
+
+ if (comname && (!SYMBOL_LINKAGE_NAME (sym)
+ || strcmp (comname, SYMBOL_LINKAGE_NAME (sym)) != 0))
+ continue;
+
+ if (*any_printed)
+ putchar_filtered ('\n');
+ else
+ *any_printed = 1;
+ if (SYMBOL_PRINT_NAME (sym))
+ printf_filtered (_("Contents of F77 COMMON block '%s':\n"),
+ SYMBOL_PRINT_NAME (sym));
+ else
+ printf_filtered (_("Contents of blank COMMON block:\n"));
+
+ for (index = 0; index < common->n_entries; index++)
+ {
+ struct value *val = NULL;
+
+ printf_filtered ("%s = ",
+ SYMBOL_PRINT_NAME (common->contents[index]));
+
+ try
+ {
+ val = value_of_variable (common->contents[index], block);
+ value_print (val, gdb_stdout, &opts);
+ }
+
+ catch (const gdb_exception_error &except)
+ {
+ fprintf_styled (gdb_stdout, metadata_style.style (),
+ "<error reading variable: %s>",
+ except.what ());
+ }
+
+ putchar_filtered ('\n');
+ }
+ }