aboutsummaryrefslogtreecommitdiff
path: root/gdb/debuginfod-support.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/debuginfod-support.c')
-rw-r--r--gdb/debuginfod-support.c170
1 files changed, 74 insertions, 96 deletions
diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c
index 04d254a..0e25fc9 100644
--- a/gdb/debuginfod-support.c
+++ b/gdb/debuginfod-support.c
@@ -35,13 +35,8 @@ static const char debuginfod_on[] = "on";
static const char debuginfod_off[] = "off";
static const char debuginfod_ask[] = "ask";
-static const char *debuginfod_enabled_enum[] =
-{
- debuginfod_on,
- debuginfod_off,
- debuginfod_ask,
- nullptr
-};
+static const char *debuginfod_enabled_enum[]
+ = { debuginfod_on, debuginfod_off, debuginfod_ask, nullptr };
static const char *debuginfod_enabled =
#if defined(HAVE_LIBDEBUGINFOD)
@@ -54,8 +49,7 @@ static unsigned int debuginfod_verbose = 1;
#ifndef HAVE_LIBDEBUGINFOD
scoped_fd
-debuginfod_source_query (const unsigned char *build_id,
- int build_id_len,
+debuginfod_source_query (const unsigned char *build_id, int build_id_len,
const char *srcpath,
gdb::unique_xmalloc_ptr<char> *destname)
{
@@ -63,8 +57,7 @@ debuginfod_source_query (const unsigned char *build_id,
}
scoped_fd
-debuginfod_debuginfo_query (const unsigned char *build_id,
- int build_id_len,
+debuginfod_debuginfo_query (const unsigned char *build_id, int build_id_len,
const char *filename,
gdb::unique_xmalloc_ptr<char> *destname)
{
@@ -72,15 +65,14 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
}
scoped_fd
-debuginfod_exec_query (const unsigned char *build_id,
- int build_id_len,
+debuginfod_exec_query (const unsigned char *build_id, int build_id_len,
const char *filename,
gdb::unique_xmalloc_ptr<char> *destname)
{
return scoped_fd (-ENOSYS);
}
-#define NO_IMPL _("Support for debuginfod is not compiled into GDB.")
+#define NO_IMPL _ ("Support for debuginfod is not compiled into GDB.")
#else
#include <elfutils/debuginfod.h>
@@ -88,11 +80,13 @@ debuginfod_exec_query (const unsigned char *build_id,
struct user_data
{
user_data (const char *desc, const char *fname)
- : desc (desc), fname (fname)
- { }
+ : desc (desc),
+ fname (fname)
+ {
+ }
- const char * const desc;
- const char * const fname;
+ const char *const desc;
+ const char *const fname;
ui_out::progress_update progress;
};
@@ -100,16 +94,12 @@ struct user_data
struct debuginfod_client_deleter
{
- void operator() (debuginfod_client *c)
- {
- debuginfod_end (c);
- }
+ void operator() (debuginfod_client *c) { debuginfod_end (c); }
};
using debuginfod_client_up
= std::unique_ptr<debuginfod_client, debuginfod_client_deleter>;
-
/* Convert SIZE into a unit suitable for use with progress updates.
SIZE should in given in bytes and will be converted into KB, MB, GB
or remain unchanged. UNIT will be set to "B", "KB", "MB" or "GB"
@@ -143,13 +133,12 @@ progressfn (debuginfod_client *c, long cur, long total)
gdb_assert (data != nullptr);
string_file styled_fname (current_uiout->can_emit_style_escape ());
- fprintf_styled (&styled_fname, file_name_style.style (), "%s",
- data->fname);
+ fprintf_styled (&styled_fname, file_name_style.style (), "%s", data->fname);
if (check_quit_flag ())
{
- gdb_printf ("Cancelling download of %s %s...\n",
- data->desc, styled_fname.c_str ());
+ gdb_printf ("Cancelling download of %s %s...\n", data->desc,
+ styled_fname.c_str ());
return 1;
}
@@ -165,17 +154,17 @@ progressfn (debuginfod_client *c, long cur, long total)
if (howmuch >= 0.0 && howmuch <= 1.0)
{
double d_total = (double) total;
- const char *unit = get_size_and_unit (d_total);
- std::string msg = string_printf ("Downloading %0.2f %s %s %s",
- d_total, unit, data->desc,
- styled_fname.c_str ());
+ const char *unit = get_size_and_unit (d_total);
+ std::string msg
+ = string_printf ("Downloading %0.2f %s %s %s", d_total, unit,
+ data->desc, styled_fname.c_str ());
data->progress.update_progress (msg, unit, howmuch, d_total);
return 0;
}
}
- std::string msg = string_printf ("Downloading %s %s",
- data->desc, styled_fname.c_str ());
+ std::string msg
+ = string_printf ("Downloading %s %s", data->desc, styled_fname.c_str ());
data->progress.update_progress (msg);
return 0;
}
@@ -204,15 +193,13 @@ debuginfod_is_enabled ()
{
const char *urls = skip_spaces (getenv (DEBUGINFOD_URLS_ENV_VAR));
- if (debuginfod_enabled == debuginfod_off
- || urls == nullptr
- || *urls == '\0')
+ if (debuginfod_enabled == debuginfod_off || urls == nullptr || *urls == '\0')
return false;
if (debuginfod_enabled == debuginfod_ask)
{
- gdb_printf (_("\nThis GDB supports auto-downloading debuginfo " \
- "from the following URLs:\n"));
+ gdb_printf (_ ("\nThis GDB supports auto-downloading debuginfo "
+ "from the following URLs:\n"));
gdb::string_view url_view (urls);
while (true)
@@ -229,29 +216,28 @@ debuginfod_is_enabled ()
DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD
off = url_view.find_first_of (' ');
DIAGNOSTIC_POP
- gdb_printf
- (_(" <%ps>\n"),
- styled_string (file_name_style.style (),
- gdb::to_string (url_view.substr (0,
- off)).c_str ()));
+ gdb_printf (_ (" <%ps>\n"),
+ styled_string (
+ file_name_style.style (),
+ gdb::to_string (url_view.substr (0, off)).c_str ()));
if (off == gdb::string_view::npos)
break;
url_view = url_view.substr (off);
}
- int resp = nquery (_("Enable debuginfod for this session? "));
+ int resp = nquery (_ ("Enable debuginfod for this session? "));
if (!resp)
{
- gdb_printf (_("Debuginfod has been disabled.\nTo make this " \
- "setting permanent, add \'set debuginfod " \
- "enabled off\' to .gdbinit.\n"));
+ gdb_printf (_ ("Debuginfod has been disabled.\nTo make this "
+ "setting permanent, add \'set debuginfod "
+ "enabled off\' to .gdbinit.\n"));
debuginfod_enabled = debuginfod_off;
return false;
}
- gdb_printf (_("Debuginfod has been enabled.\nTo make this " \
- "setting permanent, add \'set debuginfod enabled " \
- "on\' to .gdbinit.\n"));
+ gdb_printf (_ ("Debuginfod has been enabled.\nTo make this "
+ "setting permanent, add \'set debuginfod enabled "
+ "on\' to .gdbinit.\n"));
debuginfod_enabled = debuginfod_on;
}
@@ -267,17 +253,15 @@ print_outcome (user_data &data, int fd)
current_uiout->do_progress_end ();
if (fd < 0 && fd != -ENOENT)
- gdb_printf (_("Download failed: %s. Continuing without %s %ps.\n"),
- safe_strerror (-fd),
- data.desc,
+ gdb_printf (_ ("Download failed: %s. Continuing without %s %ps.\n"),
+ safe_strerror (-fd), data.desc,
styled_string (file_name_style.style (), data.fname));
}
/* See debuginfod-support.h */
scoped_fd
-debuginfod_source_query (const unsigned char *build_id,
- int build_id_len,
+debuginfod_source_query (const unsigned char *build_id, int build_id_len,
const char *srcpath,
gdb::unique_xmalloc_ptr<char> *destname)
{
@@ -300,10 +284,7 @@ debuginfod_source_query (const unsigned char *build_id,
target_terminal::ours ();
}
- scoped_fd fd (debuginfod_find_source (c,
- build_id,
- build_id_len,
- srcpath,
+ scoped_fd fd (debuginfod_find_source (c, build_id, build_id_len, srcpath,
&dname));
debuginfod_set_user_data (c, nullptr);
print_outcome (data, fd.get ());
@@ -317,8 +298,7 @@ debuginfod_source_query (const unsigned char *build_id,
/* See debuginfod-support.h */
scoped_fd
-debuginfod_debuginfo_query (const unsigned char *build_id,
- int build_id_len,
+debuginfod_debuginfo_query (const unsigned char *build_id, int build_id_len,
const char *filename,
gdb::unique_xmalloc_ptr<char> *destname)
{
@@ -341,8 +321,7 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
target_terminal::ours ();
}
- scoped_fd fd (debuginfod_find_debuginfo (c, build_id, build_id_len,
- &dname));
+ scoped_fd fd (debuginfod_find_debuginfo (c, build_id, build_id_len, &dname));
debuginfod_set_user_data (c, nullptr);
print_outcome (data, fd.get ());
@@ -355,8 +334,7 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
/* See debuginfod-support.h */
scoped_fd
-debuginfod_exec_query (const unsigned char *build_id,
- int build_id_len,
+debuginfod_exec_query (const unsigned char *build_id, int build_id_len,
const char *filename,
gdb::unique_xmalloc_ptr<char> *destname)
{
@@ -379,7 +357,8 @@ debuginfod_exec_query (const unsigned char *build_id,
target_terminal::ours ();
}
- scoped_fd fd (debuginfod_find_executable (c, build_id, build_id_len, &dname));
+ scoped_fd fd (debuginfod_find_executable (c, build_id, build_id_len,
+ &dname));
debuginfod_set_user_data (c, nullptr);
print_outcome (data, fd.get ());
@@ -419,8 +398,9 @@ show_debuginfod_enabled (ui_file *file, int from_tty, cmd_list_element *cmd,
const char *value)
{
gdb_printf (file,
- _("Debuginfod functionality is currently set to "
- "\"%s\".\n"), debuginfod_enabled);
+ _ ("Debuginfod functionality is currently set to "
+ "\"%s\".\n"),
+ debuginfod_enabled);
}
/* Set callback for "set debuginfod urls". */
@@ -430,7 +410,7 @@ set_debuginfod_urls (const std::string &urls)
{
#if defined(HAVE_LIBDEBUGINFOD)
if (setenv (DEBUGINFOD_URLS_ENV_VAR, urls.c_str (), 1) != 0)
- warning (_("Unable to set debuginfod URLs: %s"), safe_strerror (errno));
+ warning (_ ("Unable to set debuginfod URLs: %s"), safe_strerror (errno));
#else
error (NO_IMPL);
#endif
@@ -438,7 +418,7 @@ set_debuginfod_urls (const std::string &urls)
/* Get callback for "set debuginfod urls". */
-static const std::string&
+static const std::string &
get_debuginfod_urls ()
{
static std::string urls;
@@ -461,9 +441,9 @@ show_debuginfod_urls (ui_file *file, int from_tty, cmd_list_element *cmd,
const char *value)
{
if (value[0] == '\0')
- gdb_printf (file, _("Debuginfod URLs have not been set.\n"));
+ gdb_printf (file, _ ("Debuginfod URLs have not been set.\n"));
else
- gdb_printf (file, _("Debuginfod URLs are currently set to:\n%s\n"),
+ gdb_printf (file, _ ("Debuginfod URLs are currently set to:\n%s\n"),
value);
}
@@ -473,58 +453,56 @@ static void
show_debuginfod_verbose_command (ui_file *file, int from_tty,
cmd_list_element *cmd, const char *value)
{
- gdb_printf (file, _("Debuginfod verbose output is set to %s.\n"),
- value);
+ gdb_printf (file, _ ("Debuginfod verbose output is set to %s.\n"), value);
}
/* Register debuginfod commands. */
void _initialize_debuginfod ();
+
void
_initialize_debuginfod ()
{
/* set/show debuginfod */
add_setshow_prefix_cmd ("debuginfod", class_run,
- _("Set debuginfod options."),
- _("Show debuginfod options."),
+ _ ("Set debuginfod options."),
+ _ ("Show debuginfod options."),
&set_debuginfod_prefix_list,
- &show_debuginfod_prefix_list,
- &setlist, &showlist);
+ &show_debuginfod_prefix_list, &setlist, &showlist);
add_setshow_enum_cmd ("enabled", class_run, debuginfod_enabled_enum,
- _("Set whether to use debuginfod."),
- _("Show whether to use debuginfod."),
- _("\
+ _ ("Set whether to use debuginfod."),
+ _ ("Show whether to use debuginfod."), _ ("\
When on, enable the use of debuginfod to download missing debug info and\n\
source files."),
- set_debuginfod_enabled,
- get_debuginfod_enabled,
- show_debuginfod_enabled,
- &set_debuginfod_prefix_list,
+ set_debuginfod_enabled, get_debuginfod_enabled,
+ show_debuginfod_enabled, &set_debuginfod_prefix_list,
&show_debuginfod_prefix_list);
/* set/show debuginfod urls */
- add_setshow_string_noescape_cmd ("urls", class_run, _("\
-Set the list of debuginfod server URLs."), _("\
-Show the list of debuginfod server URLs."), _("\
+ add_setshow_string_noescape_cmd ("urls", class_run, _ ("\
+Set the list of debuginfod server URLs."),
+ _ ("\
+Show the list of debuginfod server URLs."),
+ _ ("\
Manage the space-separated list of debuginfod server URLs that GDB will query \
when missing debuginfo, executables or source files.\nThe default value is \
copied from the DEBUGINFOD_URLS environment variable."),
- set_debuginfod_urls,
- get_debuginfod_urls,
+ set_debuginfod_urls, get_debuginfod_urls,
show_debuginfod_urls,
&set_debuginfod_prefix_list,
&show_debuginfod_prefix_list);
/* set/show debuginfod verbose */
- add_setshow_zuinteger_cmd ("verbose", class_support,
- &debuginfod_verbose, _("\
-Set verbosity of debuginfod output."), _("\
-Show debuginfod debugging."), _("\
+ add_setshow_zuinteger_cmd ("verbose", class_support, &debuginfod_verbose,
+ _ ("\
+Set verbosity of debuginfod output."),
+ _ ("\
+Show debuginfod debugging."),
+ _ ("\
When set to a non-zero value, display verbose output for each debuginfod \
query.\nTo disable, set to zero. Verbose output is displayed by default."),
- nullptr,
- show_debuginfod_verbose_command,
+ nullptr, show_debuginfod_verbose_command,
&set_debuginfod_prefix_list,
&show_debuginfod_prefix_list);
}