gdb/symfile-debug.c - gdb

Global variables defined

Data types defined

Functions defined

Macros defined

Source code

  1. /* Debug logging for the symbol file functions for the GNU debugger, GDB.

  2.    Copyright (C) 2013-2015 Free Software Foundation, Inc.

  3.    Contributed by Cygnus Support, using pieces from other GDB modules.

  4.    This file is part of GDB.

  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 3 of the License, or
  8.    (at your option) any later version.

  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.

  13.    You should have received a copy of the GNU General Public License
  14.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  15. /* Note: Be careful with functions that can throw errors.
  16.    We want to see a logging message regardless of whether an error was thrown.
  17.    This typically means printing a message before calling the real function
  18.    and then if the function returns a result printing a message after it
  19.    returns.  */

  20. #include "defs.h"
  21. #include "gdbcmd.h"
  22. #include "objfiles.h"
  23. #include "observer.h"
  24. #include "source.h"
  25. #include "symtab.h"
  26. #include "symfile.h"

  27. /* We need to save a pointer to the real symbol functions.
  28.    Plus, the debug versions are malloc'd because we have to NULL out the
  29.    ones that are NULL in the real copy.  */

  30. struct debug_sym_fns_data
  31. {
  32.   const struct sym_fns *real_sf;
  33.   struct sym_fns debug_sf;
  34. };

  35. /* We need to record a pointer to the real set of functions for each
  36.    objfile.  */
  37. static const struct objfile_data *symfile_debug_objfile_data_key;

  38. /* If non-zero all calls to the symfile functions are logged.  */
  39. static int debug_symfile = 0;

  40. /* Return non-zero if symfile debug logging is installed.  */

  41. static int
  42. symfile_debug_installed (struct objfile *objfile)
  43. {
  44.   return (objfile->sf != NULL
  45.           && objfile_data (objfile, symfile_debug_objfile_data_key) != NULL);
  46. }

  47. /* Utility return the name to print for SYMTAB.  */

  48. static const char *
  49. debug_symtab_name (struct symtab *symtab)
  50. {
  51.   return symtab_to_filename_for_display (symtab);
  52. }

  53. /* Debugging version of struct quick_symbol_functions.  */

  54. static int
  55. debug_qf_has_symbols (struct objfile *objfile)
  56. {
  57.   const struct debug_sym_fns_data *debug_data =
  58.     objfile_data (objfile, symfile_debug_objfile_data_key);
  59.   int retval;

  60.   retval = debug_data->real_sf->qf->has_symbols (objfile);

  61.   fprintf_filtered (gdb_stdlog, "qf->has_symbols (%s) = %d\n",
  62.                     objfile_debug_name (objfile), retval);

  63.   return retval;
  64. }

  65. static struct symtab *
  66. debug_qf_find_last_source_symtab (struct objfile *objfile)
  67. {
  68.   const struct debug_sym_fns_data *debug_data =
  69.     objfile_data (objfile, symfile_debug_objfile_data_key);
  70.   struct symtab *retval;

  71.   fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (%s)\n",
  72.                     objfile_debug_name (objfile));

  73.   retval = debug_data->real_sf->qf->find_last_source_symtab (objfile);

  74.   fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (...) = %s\n",
  75.                     retval ? debug_symtab_name (retval) : "NULL");

  76.   return retval;
  77. }

  78. static void
  79. debug_qf_forget_cached_source_info (struct objfile *objfile)
  80. {
  81.   const struct debug_sym_fns_data *debug_data =
  82.     objfile_data (objfile, symfile_debug_objfile_data_key);

  83.   fprintf_filtered (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
  84.                     objfile_debug_name (objfile));

  85.   debug_data->real_sf->qf->forget_cached_source_info (objfile);
  86. }

  87. static int
  88. debug_qf_map_symtabs_matching_filename (struct objfile *objfile,
  89.                                         const char *name,
  90.                                         const char *real_path,
  91.                                         int (*callback) (struct symtab *,
  92.                                                          void *),
  93.                                         void *data)
  94. {
  95.   const struct debug_sym_fns_data *debug_data =
  96.     objfile_data (objfile, symfile_debug_objfile_data_key);
  97.   int retval;

  98.   fprintf_filtered (gdb_stdlog,
  99.                     "qf->map_symtabs_matching_filename (%s, \"%s\", \"%s\", %s, %s)\n",
  100.                     objfile_debug_name (objfile), name,
  101.                     real_path ? real_path : NULL,
  102.                     host_address_to_string (callback),
  103.                     host_address_to_string (data));

  104.   retval = debug_data->real_sf->qf->map_symtabs_matching_filename
  105.     (objfile, name, real_path, callback, data);

  106.   fprintf_filtered (gdb_stdlog,
  107.                     "qf->map_symtabs_matching_filename (...) = %d\n",
  108.                     retval);

  109.   return retval;
  110. }

  111. static struct compunit_symtab *
  112. debug_qf_lookup_symbol (struct objfile *objfile, int kind, const char *name,
  113.                         domain_enum domain)
  114. {
  115.   const struct debug_sym_fns_data *debug_data =
  116.     objfile_data (objfile, symfile_debug_objfile_data_key);
  117.   struct compunit_symtab *retval;

  118.   fprintf_filtered (gdb_stdlog,
  119.                     "qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
  120.                     objfile_debug_name (objfile), kind, name,
  121.                     domain_name (domain));

  122.   retval = debug_data->real_sf->qf->lookup_symbol (objfile, kind, name,
  123.                                                    domain);

  124.   fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (...) = %s\n",
  125.                     retval
  126.                     ? debug_symtab_name (compunit_primary_filetab (retval))
  127.                     : "NULL");

  128.   return retval;
  129. }

  130. static void
  131. debug_qf_print_stats (struct objfile *objfile)
  132. {
  133.   const struct debug_sym_fns_data *debug_data =
  134.     objfile_data (objfile, symfile_debug_objfile_data_key);

  135.   fprintf_filtered (gdb_stdlog, "qf->print_stats (%s)\n",
  136.                     objfile_debug_name (objfile));

  137.   debug_data->real_sf->qf->print_stats (objfile);
  138. }

  139. static void
  140. debug_qf_dump (struct objfile *objfile)
  141. {
  142.   const struct debug_sym_fns_data *debug_data =
  143.     objfile_data (objfile, symfile_debug_objfile_data_key);

  144.   fprintf_filtered (gdb_stdlog, "qf->dump (%s)\n",
  145.                     objfile_debug_name (objfile));

  146.   debug_data->real_sf->qf->dump (objfile);
  147. }

  148. static void
  149. debug_qf_relocate (struct objfile *objfile,
  150.                    const struct section_offsets *new_offsets,
  151.                    const struct section_offsets *delta)
  152. {
  153.   const struct debug_sym_fns_data *debug_data =
  154.     objfile_data (objfile, symfile_debug_objfile_data_key);

  155.   fprintf_filtered (gdb_stdlog, "qf->relocate (%s, %s, %s)\n",
  156.                     objfile_debug_name (objfile),
  157.                     host_address_to_string (new_offsets),
  158.                     host_address_to_string (delta));

  159.   debug_data->real_sf->qf->relocate (objfile, new_offsets, delta);
  160. }

  161. static void
  162. debug_qf_expand_symtabs_for_function (struct objfile *objfile,
  163.                                       const char *func_name)
  164. {
  165.   const struct debug_sym_fns_data *debug_data =
  166.     objfile_data (objfile, symfile_debug_objfile_data_key);

  167.   fprintf_filtered (gdb_stdlog,
  168.                     "qf->expand_symtabs_for_function (%s, \"%s\")\n",
  169.                     objfile_debug_name (objfile), func_name);

  170.   debug_data->real_sf->qf->expand_symtabs_for_function (objfile, func_name);
  171. }

  172. static void
  173. debug_qf_expand_all_symtabs (struct objfile *objfile)
  174. {
  175.   const struct debug_sym_fns_data *debug_data =
  176.     objfile_data (objfile, symfile_debug_objfile_data_key);

  177.   fprintf_filtered (gdb_stdlog, "qf->expand_all_symtabs (%s)\n",
  178.                     objfile_debug_name (objfile));

  179.   debug_data->real_sf->qf->expand_all_symtabs (objfile);
  180. }

  181. static void
  182. debug_qf_expand_symtabs_with_fullname (struct objfile *objfile,
  183.                                        const char *fullname)
  184. {
  185.   const struct debug_sym_fns_data *debug_data =
  186.     objfile_data (objfile, symfile_debug_objfile_data_key);

  187.   fprintf_filtered (gdb_stdlog,
  188.                     "qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
  189.                     objfile_debug_name (objfile), fullname);

  190.   debug_data->real_sf->qf->expand_symtabs_with_fullname (objfile, fullname);
  191. }

  192. static void
  193. debug_qf_map_matching_symbols (struct objfile *objfile,
  194.                                const char *name, domain_enum namespace,
  195.                                int global,
  196.                                int (*callback) (struct block *,
  197.                                                 struct symbol *, void *),
  198.                                void *data,
  199.                                symbol_compare_ftype *match,
  200.                                symbol_compare_ftype *ordered_compare)
  201. {
  202.   const struct debug_sym_fns_data *debug_data =
  203.     objfile_data (objfile, symfile_debug_objfile_data_key);

  204.   fprintf_filtered (gdb_stdlog,
  205.                     "qf->map_matching_symbols (%s, \"%s\", %s, %d, %s, %s, %s, %s)\n",
  206.                     objfile_debug_name (objfile), name,
  207.                     domain_name (namespace), global,
  208.                     host_address_to_string (callback),
  209.                     host_address_to_string (data),
  210.                     host_address_to_string (match),
  211.                     host_address_to_string (ordered_compare));

  212.   debug_data->real_sf->qf->map_matching_symbols (objfile, name,
  213.                                                  namespace, global,
  214.                                                  callback, data,
  215.                                                  match,
  216.                                                  ordered_compare);
  217. }

  218. static void
  219. debug_qf_expand_symtabs_matching
  220.   (struct objfile *objfile,
  221.    expand_symtabs_file_matcher_ftype *file_matcher,
  222.    expand_symtabs_symbol_matcher_ftype *symbol_matcher,
  223.    enum search_domain kind, void *data)
  224. {
  225.   const struct debug_sym_fns_data *debug_data =
  226.     objfile_data (objfile, symfile_debug_objfile_data_key);

  227.   fprintf_filtered (gdb_stdlog,
  228.                     "qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n",
  229.                     objfile_debug_name (objfile),
  230.                     host_address_to_string (file_matcher),
  231.                     host_address_to_string (symbol_matcher),
  232.                     search_domain_name (kind),
  233.                     host_address_to_string (data));

  234.   debug_data->real_sf->qf->expand_symtabs_matching (objfile,
  235.                                                     file_matcher,
  236.                                                     symbol_matcher,
  237.                                                     kind, data);
  238. }

  239. static struct compunit_symtab *
  240. debug_qf_find_pc_sect_compunit_symtab (struct objfile *objfile,
  241.                                        struct bound_minimal_symbol msymbol,
  242.                                        CORE_ADDR pc,
  243.                                        struct obj_section *section,
  244.                                        int warn_if_readin)
  245. {
  246.   const struct debug_sym_fns_data *debug_data =
  247.     objfile_data (objfile, symfile_debug_objfile_data_key);
  248.   struct compunit_symtab *retval;

  249.   fprintf_filtered (gdb_stdlog,
  250.                     "qf->find_pc_sect_compunit_symtab (%s, %s, %s, %s, %d)\n",
  251.                     objfile_debug_name (objfile),
  252.                     host_address_to_string (msymbol.minsym),
  253.                     hex_string (pc),
  254.                     host_address_to_string (section),
  255.                     warn_if_readin);

  256.   retval
  257.     = debug_data->real_sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol,
  258.                                                              pc, section,
  259.                                                              warn_if_readin);

  260.   fprintf_filtered (gdb_stdlog,
  261.                     "qf->find_pc_sect_compunit_symtab (...) = %s\n",
  262.                     retval
  263.                     ? debug_symtab_name (compunit_primary_filetab (retval))
  264.                     : "NULL");

  265.   return retval;
  266. }

  267. static void
  268. debug_qf_map_symbol_filenames (struct objfile *objfile,
  269.                                symbol_filename_ftype *fun, void *data,
  270.                                int need_fullname)
  271. {
  272.   const struct debug_sym_fns_data *debug_data =
  273.     objfile_data (objfile, symfile_debug_objfile_data_key);
  274.   fprintf_filtered (gdb_stdlog,
  275.                     "qf->map_symbol_filenames (%s, %s, %s, %d)\n",
  276.                     objfile_debug_name (objfile),
  277.                     host_address_to_string (fun),
  278.                     host_address_to_string (data),
  279.                     need_fullname);

  280.   debug_data->real_sf->qf->map_symbol_filenames (objfile, fun, data,
  281.                                                  need_fullname);
  282. }

  283. static const struct quick_symbol_functions debug_sym_quick_functions =
  284. {
  285.   debug_qf_has_symbols,
  286.   debug_qf_find_last_source_symtab,
  287.   debug_qf_forget_cached_source_info,
  288.   debug_qf_map_symtabs_matching_filename,
  289.   debug_qf_lookup_symbol,
  290.   debug_qf_print_stats,
  291.   debug_qf_dump,
  292.   debug_qf_relocate,
  293.   debug_qf_expand_symtabs_for_function,
  294.   debug_qf_expand_all_symtabs,
  295.   debug_qf_expand_symtabs_with_fullname,
  296.   debug_qf_map_matching_symbols,
  297.   debug_qf_expand_symtabs_matching,
  298.   debug_qf_find_pc_sect_compunit_symtab,
  299.   debug_qf_map_symbol_filenames
  300. };

  301. /* Debugging version of struct sym_probe_fns.  */

  302. static VEC (probe_p) *
  303. debug_sym_get_probes (struct objfile *objfile)
  304. {
  305.   const struct debug_sym_fns_data *debug_data =
  306.     objfile_data (objfile, symfile_debug_objfile_data_key);
  307.   VEC (probe_p) *retval;

  308.   retval = debug_data->real_sf->sym_probe_fns->sym_get_probes (objfile);

  309.   fprintf_filtered (gdb_stdlog,
  310.                     "probes->sym_get_probes (%s) = %s\n",
  311.                     objfile_debug_name (objfile),
  312.                     host_address_to_string (retval));

  313.   return retval;
  314. }

  315. static const struct sym_probe_fns debug_sym_probe_fns =
  316. {
  317.   debug_sym_get_probes,
  318. };

  319. /* Debugging version of struct sym_fns.  */

  320. static void
  321. debug_sym_new_init (struct objfile *objfile)
  322. {
  323.   const struct debug_sym_fns_data *debug_data =
  324.     objfile_data (objfile, symfile_debug_objfile_data_key);

  325.   fprintf_filtered (gdb_stdlog, "sf->sym_new_init (%s)\n",
  326.                     objfile_debug_name (objfile));

  327.   debug_data->real_sf->sym_new_init (objfile);
  328. }

  329. static void
  330. debug_sym_init (struct objfile *objfile)
  331. {
  332.   const struct debug_sym_fns_data *debug_data =
  333.     objfile_data (objfile, symfile_debug_objfile_data_key);

  334.   fprintf_filtered (gdb_stdlog, "sf->sym_init (%s)\n",
  335.                     objfile_debug_name (objfile));

  336.   debug_data->real_sf->sym_init (objfile);
  337. }

  338. static void
  339. debug_sym_read (struct objfile *objfile, int symfile_flags)
  340. {
  341.   const struct debug_sym_fns_data *debug_data =
  342.     objfile_data (objfile, symfile_debug_objfile_data_key);

  343.   fprintf_filtered (gdb_stdlog, "sf->sym_read (%s, 0x%x)\n",
  344.                     objfile_debug_name (objfile), symfile_flags);

  345.   debug_data->real_sf->sym_read (objfile, symfile_flags);
  346. }

  347. static void
  348. debug_sym_read_psymbols (struct objfile *objfile)
  349. {
  350.   const struct debug_sym_fns_data *debug_data =
  351.     objfile_data (objfile, symfile_debug_objfile_data_key);

  352.   fprintf_filtered (gdb_stdlog, "sf->sym_read_psymbols (%s)\n",
  353.                     objfile_debug_name (objfile));

  354.   debug_data->real_sf->sym_read_psymbols (objfile);
  355. }

  356. static void
  357. debug_sym_finish (struct objfile *objfile)
  358. {
  359.   const struct debug_sym_fns_data *debug_data =
  360.     objfile_data (objfile, symfile_debug_objfile_data_key);

  361.   fprintf_filtered (gdb_stdlog, "sf->sym_finish (%s)\n",
  362.                     objfile_debug_name (objfile));

  363.   debug_data->real_sf->sym_finish (objfile);
  364. }

  365. static void
  366. debug_sym_offsets (struct objfile *objfile,
  367.                    const struct section_addr_info *info)
  368. {
  369.   const struct debug_sym_fns_data *debug_data =
  370.     objfile_data (objfile, symfile_debug_objfile_data_key);

  371.   fprintf_filtered (gdb_stdlog, "sf->sym_offsets (%s, %s)\n",
  372.                     objfile_debug_name (objfile),
  373.                     host_address_to_string (info));

  374.   debug_data->real_sf->sym_offsets (objfile, info);
  375. }

  376. static struct symfile_segment_data *
  377. debug_sym_segments (bfd *abfd)
  378. {
  379.   /* This API function is annoying, it doesn't take a "this" pointer.
  380.      Fortunately it is only used in one place where we (re-)lookup the
  381.      sym_fns table to use.  Thus we will never be called.  */
  382.   gdb_assert_not_reached ("debug_sym_segments called");
  383. }

  384. static void
  385. debug_sym_read_linetable (struct objfile *objfile)
  386. {
  387.   const struct debug_sym_fns_data *debug_data =
  388.     objfile_data (objfile, symfile_debug_objfile_data_key);

  389.   fprintf_filtered (gdb_stdlog, "sf->sym_read_linetable (%s)\n",
  390.                     objfile_debug_name (objfile));

  391.   debug_data->real_sf->sym_read_linetable (objfile);
  392. }

  393. static bfd_byte *
  394. debug_sym_relocate (struct objfile *objfile, asection *sectp, bfd_byte *buf)
  395. {
  396.   const struct debug_sym_fns_data *debug_data =
  397.     objfile_data (objfile, symfile_debug_objfile_data_key);
  398.   bfd_byte *retval;

  399.   retval = debug_data->real_sf->sym_relocate (objfile, sectp, buf);

  400.   fprintf_filtered (gdb_stdlog,
  401.                     "sf->sym_relocate (%s, %s, %s) = %s\n",
  402.                     objfile_debug_name (objfile),
  403.                     host_address_to_string (sectp),
  404.                     host_address_to_string (buf),
  405.                     host_address_to_string (retval));

  406.   return retval;
  407. }

  408. /* Template of debugging version of struct sym_fns.
  409.    A copy is made, with sym_flavour updated, and a pointer to the real table
  410.    installed in real_sf, and then a pointer to the copy is installed in the
  411.    objfile.  */

  412. static const struct sym_fns debug_sym_fns =
  413. {
  414.   debug_sym_new_init,
  415.   debug_sym_init,
  416.   debug_sym_read,
  417.   debug_sym_read_psymbols,
  418.   debug_sym_finish,
  419.   debug_sym_offsets,
  420.   debug_sym_segments,
  421.   debug_sym_read_linetable,
  422.   debug_sym_relocate,
  423.   &debug_sym_probe_fns,
  424.   &debug_sym_quick_functions
  425. };

  426. /* Free the copy of sym_fns recorded in the registry.  */

  427. static void
  428. symfile_debug_free_objfile (struct objfile *objfile, void *datum)
  429. {
  430.   xfree (datum);
  431. }

  432. /* Install the debugging versions of the symfile functions for OBJFILE.
  433.    Do not call this if the debug versions are already installed.  */

  434. static void
  435. install_symfile_debug_logging (struct objfile *objfile)
  436. {
  437.   const struct sym_fns *real_sf;
  438.   struct debug_sym_fns_data *debug_data;

  439.   /* The debug versions should not already be installed.  */
  440.   gdb_assert (!symfile_debug_installed (objfile));

  441.   real_sf = objfile->sf;

  442.   /* Alas we have to preserve NULL entries in REAL_SF.  */
  443.   debug_data = XCNEW (struct debug_sym_fns_data);

  444. #define COPY_SF_PTR(from, to, name, func)        \
  445.   do {                                                \
  446.     if ((from)->name)                                \
  447.       (to)->debug_sf.name = func;                \
  448.   } while (0)

  449.   COPY_SF_PTR (real_sf, debug_data, sym_new_init, debug_sym_new_init);
  450.   COPY_SF_PTR (real_sf, debug_data, sym_init, debug_sym_init);
  451.   COPY_SF_PTR (real_sf, debug_data, sym_read, debug_sym_read);
  452.   COPY_SF_PTR (real_sf, debug_data, sym_read_psymbols,
  453.                debug_sym_read_psymbols);
  454.   COPY_SF_PTR (real_sf, debug_data, sym_finish, debug_sym_finish);
  455.   COPY_SF_PTR (real_sf, debug_data, sym_offsets, debug_sym_offsets);
  456.   COPY_SF_PTR (real_sf, debug_data, sym_segments, debug_sym_segments);
  457.   COPY_SF_PTR (real_sf, debug_data, sym_read_linetable,
  458.                debug_sym_read_linetable);
  459.   COPY_SF_PTR (real_sf, debug_data, sym_relocate, debug_sym_relocate);
  460.   if (real_sf->sym_probe_fns)
  461.     debug_data->debug_sf.sym_probe_fns = &debug_sym_probe_fns;
  462.   debug_data->debug_sf.qf = &debug_sym_quick_functions;

  463. #undef COPY_SF_PTR

  464.   debug_data->real_sf = real_sf;
  465.   set_objfile_data (objfile, symfile_debug_objfile_data_key, debug_data);
  466.   objfile->sf = &debug_data->debug_sf;
  467. }

  468. /* Uninstall the debugging versions of the symfile functions for OBJFILE.
  469.    Do not call this if the debug versions are not installed.  */

  470. static void
  471. uninstall_symfile_debug_logging (struct objfile *objfile)
  472. {
  473.   struct debug_sym_fns_data *debug_data;

  474.   /* The debug versions should be currently installed.  */
  475.   gdb_assert (symfile_debug_installed (objfile));

  476.   debug_data = objfile_data (objfile, symfile_debug_objfile_data_key);

  477.   objfile->sf = debug_data->real_sf;
  478.   xfree (debug_data);
  479.   set_objfile_data (objfile, symfile_debug_objfile_data_key, NULL);
  480. }

  481. /* Call this function to set OBJFILE->SF.
  482.    Do not set OBJFILE->SF directly.  */

  483. void
  484. objfile_set_sym_fns (struct objfile *objfile, const struct sym_fns *sf)
  485. {
  486.   if (symfile_debug_installed (objfile))
  487.     {
  488.       gdb_assert (debug_symfile);
  489.       /* Remove the current one, and reinstall a new one later.  */
  490.       uninstall_symfile_debug_logging (objfile);
  491.     }

  492.   /* Assume debug logging is disabled.  */
  493.   objfile->sf = sf;

  494.   /* Turn debug logging on if enabled.  */
  495.   if (debug_symfile)
  496.     install_symfile_debug_logging (objfile);
  497. }

  498. static void
  499. set_debug_symfile (char *args, int from_tty, struct cmd_list_element *c)
  500. {
  501.   struct program_space *pspace;
  502.   struct objfile *objfile;

  503.   ALL_PSPACES (pspace)
  504.     ALL_PSPACE_OBJFILES (pspace, objfile)
  505.     {
  506.       if (debug_symfile)
  507.         {
  508.           if (!symfile_debug_installed (objfile))
  509.             install_symfile_debug_logging (objfile);
  510.         }
  511.       else
  512.         {
  513.           if (symfile_debug_installed (objfile))
  514.             uninstall_symfile_debug_logging (objfile);
  515.         }
  516.     }
  517. }

  518. static void
  519. show_debug_symfile (struct ui_file *file, int from_tty,
  520.                         struct cmd_list_element *c, const char *value)
  521. {
  522.   fprintf_filtered (file, _("Symfile debugging is %s.\n"), value);
  523. }

  524. initialize_file_ftype _initialize_symfile_debug;

  525. void
  526. _initialize_symfile_debug (void)
  527. {
  528.   symfile_debug_objfile_data_key
  529.     = register_objfile_data_with_cleanup (NULL, symfile_debug_free_objfile);

  530.   add_setshow_boolean_cmd ("symfile", no_class, &debug_symfile, _("\
  531. Set debugging of the symfile functions."), _("\
  532. Show debugging of the symfile functions."), _("\
  533. When enabled, all calls to the symfile functions are logged."),
  534.                            set_debug_symfile, show_debug_symfile,
  535.                            &setdebuglist, &showdebuglist);

  536.   /* Note: We don't need a new-objfile observer because debug logging
  537.      will be installed when objfile init'n calls objfile_set_sym_fns.  */
  538. }