/* Skipping uninteresting files and functions while stepping.
- Copyright (C) 2011-2019 Free Software Foundation, Inc.
+ Copyright (C) 2011-2023 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "arch-utils.h"
#include "linespec.h"
#include "objfiles.h"
-#include "breakpoint.h" /* for get_sal_arch () */
+#include "breakpoint.h"
#include "source.h"
#include "filenames.h"
#include "fnmatch.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
#include "gdbsupport/gdb_optional.h"
#include <list>
#include "cli/cli-style.h"
+#include "gdbsupport/buildargv.h"
/* True if we want to print debug printouts related to file/function
skipping. */
if (m_function_is_regexp)
{
gdb_assert (!m_function.empty ());
-
- int flags = REG_NOSUB;
-#ifdef REG_EXTENDED
- flags |= REG_EXTENDED;
-#endif
-
- gdb_assert (!m_function.empty ());
- m_compiled_function_regexp.emplace (m_function.c_str (), flags,
+ m_compiled_function_regexp.emplace (m_function.c_str (),
+ REG_NOSUB | REG_EXTENDED,
_("regexp"));
}
}
skiplist_entry::add_entry (false, std::string (filename),
false, std::string ());
- printf_filtered (_("File %s will be skipped when stepping.\n"), filename);
+ gdb_printf (_("File %s will be skipped when stepping.\n"), filename);
}
/* Create a skiplist entry for the given function NAME and add it to the
{
skiplist_entry::add_entry (false, std::string (), false, std::string (name));
- printf_filtered (_("Function %s will be skipped when stepping.\n"), name);
+ gdb_printf (_("Function %s will be skipped when stepping.\n"), name);
}
static void
/* Default to the current function if no argument is given. */
if (arg == NULL)
{
+ frame_info_ptr fi = get_selected_frame (_("No default function now."));
+ struct symbol *sym = get_frame_function (fi);
const char *name = NULL;
- CORE_ADDR pc;
-
- if (!last_displayed_sal_is_valid ())
- error (_("No default function now."));
- pc = get_last_displayed_addr ();
- if (!find_pc_partial_function (pc, &name, NULL, NULL))
- {
- error (_("No function found containing current program point %s."),
- paddress (get_current_arch (), pc));
- }
+ if (sym != NULL)
+ name = sym->print_name ();
+ else
+ error (_("No function found containing current program point %s."),
+ paddress (get_current_arch (), get_frame_pc (fi)));
skip_function (name);
return;
}
if (function_to_print == NULL)
{
- printf_filtered (_("%s %s will be skipped when stepping.\n"),
- file_text, file_to_print);
+ gdb_printf (_("%s %s will be skipped when stepping.\n"),
+ file_text, file_to_print);
}
else if (file_to_print == NULL)
{
- printf_filtered (_("%s %s will be skipped when stepping.\n"),
- function_text, function_to_print);
+ gdb_printf (_("%s %s will be skipped when stepping.\n"),
+ function_text, function_to_print);
}
else
{
- printf_filtered (_("%s %s in %s %s will be skipped"
- " when stepping.\n"),
- function_text, function_to_print,
- lower_file_text, file_to_print);
+ gdb_printf (_("%s %s in %s %s will be skipped"
+ " when stepping.\n"),
+ function_text, function_to_print,
+ lower_file_text, file_to_print);
}
}
}
skiplist_entry::do_skip_file_p (const symtab_and_line &function_sal) const
{
if (debug_skip)
- fprintf_unfiltered (gdb_stdlog,
- "skip: checking if file %s matches non-glob %s...",
- function_sal.symtab->filename, m_file.c_str ());
+ gdb_printf (gdb_stdlog,
+ "skip: checking if file %s matches non-glob %s...",
+ function_sal.symtab->filename, m_file.c_str ());
bool result;
}
if (debug_skip)
- fprintf_unfiltered (gdb_stdlog, result ? "yes.\n" : "no.\n");
+ gdb_printf (gdb_stdlog, result ? "yes.\n" : "no.\n");
return result;
}
skiplist_entry::do_skip_gfile_p (const symtab_and_line &function_sal) const
{
if (debug_skip)
- fprintf_unfiltered (gdb_stdlog,
- "skip: checking if file %s matches glob %s...",
- function_sal.symtab->filename, m_file.c_str ());
+ gdb_printf (gdb_stdlog,
+ "skip: checking if file %s matches glob %s...",
+ function_sal.symtab->filename, m_file.c_str ());
bool result;
}
if (debug_skip)
- fprintf_unfiltered (gdb_stdlog, result ? "yes.\n" : "no.\n");
+ gdb_printf (gdb_stdlog, result ? "yes.\n" : "no.\n");
return result;
}
if (m_function_is_regexp)
{
if (debug_skip)
- fprintf_unfiltered (gdb_stdlog,
- "skip: checking if function %s matches regex %s...",
- function_name, m_function.c_str ());
+ gdb_printf (gdb_stdlog,
+ "skip: checking if function %s matches regex %s...",
+ function_name, m_function.c_str ());
gdb_assert (m_compiled_function_regexp);
result
else
{
if (debug_skip)
- fprintf_unfiltered (gdb_stdlog,
- ("skip: checking if function %s matches non-regex "
- "%s..."),
- function_name, m_function.c_str ());
+ gdb_printf (gdb_stdlog,
+ ("skip: checking if function %s matches non-regex "
+ "%s..."),
+ function_name, m_function.c_str ());
result = (strcmp_iw (function_name, m_function.c_str ()) == 0);
}
if (debug_skip)
- fprintf_unfiltered (gdb_stdlog, result ? "yes.\n" : "no.\n");
+ gdb_printf (gdb_stdlog, result ? "yes.\n" : "no.\n");
return result;
}
for (const skiplist_entry &entry : skiplist_entries)
{
- gdb::unique_xmalloc_ptr<char> name (xstrprintf ("%d", entry.number ()));
+ gdb::unique_xmalloc_ptr<char> name = xstrprintf ("%d", entry.number ());
if (strncmp (word, name.get (), word_len) == 0)
completer.add_completion (std::move (name));
}
}
+void _initialize_step_skip ();
void
-_initialize_step_skip (void)
+_initialize_step_skip ()
{
static struct cmd_list_element *skiplist = NULL;
struct cmd_list_element *c;
FUNCTION-SPEC is one of:\n\
-fu|-function FUNCTION-NAME\n\
-rfu|-rfunction FUNCTION-NAME-REGULAR-EXPRESSION"),
- &skiplist, "skip ", 1, &cmdlist);
+ &skiplist, 1, &cmdlist);
c = add_cmd ("file", class_breakpoint, skip_file_command, _("\
Ignore a file while stepping.\n\