Skip to content

Commit 0fea10f

Browse files
committed
Make ui_out::do_progress_end 'private'
I noticed that ui_out::do_progress_end is public, just to support one use in debuginfod-support.c. This patch makes it private, updates progress_info to call it from its destructor, and finally changes debuginfod-support.c to follow.
1 parent 442716d commit 0fea10f

File tree

2 files changed

+61
-48
lines changed

2 files changed

+61
-48
lines changed

gdb/debuginfod-support.c

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,13 @@ debuginfod_is_enabled ()
261261
/* Print the result of the most recent attempted download. */
262262

263263
static void
264-
print_outcome (user_data &data, int fd)
264+
print_outcome (int fd, const char *desc, const char *fname)
265265
{
266-
/* Clears the current line of progress output. */
267-
current_uiout->do_progress_end ();
268-
269266
if (fd < 0 && fd != -ENOENT)
270267
gdb_printf (_("Download failed: %s. Continuing without %s %ps.\n"),
271268
safe_strerror (-fd),
272-
data.desc,
273-
styled_string (file_name_style.style (), data.fname));
269+
desc,
270+
styled_string (file_name_style.style (), fname));
274271
}
275272

276273
/* See debuginfod-support.h */
@@ -290,23 +287,28 @@ debuginfod_source_query (const unsigned char *build_id,
290287
return scoped_fd (-ENOMEM);
291288

292289
char *dname = nullptr;
293-
user_data data ("source file", srcpath);
294-
295-
debuginfod_set_user_data (c, &data);
290+
scoped_fd fd;
296291
gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
297-
if (target_supports_terminal_ours ())
298-
{
299-
term_state.emplace ();
300-
target_terminal::ours ();
301-
}
302292

303-
scoped_fd fd (debuginfod_find_source (c,
304-
build_id,
305-
build_id_len,
306-
srcpath,
307-
&dname));
308-
debuginfod_set_user_data (c, nullptr);
309-
print_outcome (data, fd.get ());
293+
{
294+
user_data data ("source file", srcpath);
295+
296+
debuginfod_set_user_data (c, &data);
297+
if (target_supports_terminal_ours ())
298+
{
299+
term_state.emplace ();
300+
target_terminal::ours ();
301+
}
302+
303+
fd = scoped_fd (debuginfod_find_source (c,
304+
build_id,
305+
build_id_len,
306+
srcpath,
307+
&dname));
308+
debuginfod_set_user_data (c, nullptr);
309+
}
310+
311+
print_outcome (fd.get (), "source file", srcpath);
310312

311313
if (fd.get () >= 0)
312314
destname->reset (dname);
@@ -331,20 +333,25 @@ debuginfod_debuginfo_query (const unsigned char *build_id,
331333
return scoped_fd (-ENOMEM);
332334

333335
char *dname = nullptr;
334-
user_data data ("separate debug info for", filename);
335-
336-
debuginfod_set_user_data (c, &data);
336+
scoped_fd fd;
337337
gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
338-
if (target_supports_terminal_ours ())
339-
{
340-
term_state.emplace ();
341-
target_terminal::ours ();
342-
}
343338

344-
scoped_fd fd (debuginfod_find_debuginfo (c, build_id, build_id_len,
345-
&dname));
346-
debuginfod_set_user_data (c, nullptr);
347-
print_outcome (data, fd.get ());
339+
{
340+
user_data data ("separate debug info for", filename);
341+
342+
debuginfod_set_user_data (c, &data);
343+
if (target_supports_terminal_ours ())
344+
{
345+
term_state.emplace ();
346+
target_terminal::ours ();
347+
}
348+
349+
fd = scoped_fd (debuginfod_find_debuginfo (c, build_id, build_id_len,
350+
&dname));
351+
debuginfod_set_user_data (c, nullptr);
352+
}
353+
354+
print_outcome (fd.get (), "separate debug info for", filename);
348355

349356
if (fd.get () >= 0)
350357
destname->reset (dname);
@@ -369,19 +376,25 @@ debuginfod_exec_query (const unsigned char *build_id,
369376
return scoped_fd (-ENOMEM);
370377

371378
char *dname = nullptr;
372-
user_data data ("executable for", filename);
373-
374-
debuginfod_set_user_data (c, &data);
379+
scoped_fd fd;
375380
gdb::optional<target_terminal::scoped_restore_terminal_state> term_state;
376-
if (target_supports_terminal_ours ())
377-
{
378-
term_state.emplace ();
379-
target_terminal::ours ();
380-
}
381381

382-
scoped_fd fd (debuginfod_find_executable (c, build_id, build_id_len, &dname));
383-
debuginfod_set_user_data (c, nullptr);
384-
print_outcome (data, fd.get ());
382+
{
383+
user_data data ("executable for", filename);
384+
385+
debuginfod_set_user_data (c, &data);
386+
if (target_supports_terminal_ours ())
387+
{
388+
term_state.emplace ();
389+
target_terminal::ours ();
390+
}
391+
392+
fd = scoped_fd (debuginfod_find_executable (c, build_id, build_id_len,
393+
&dname));
394+
debuginfod_set_user_data (c, nullptr);
395+
}
396+
397+
print_outcome (fd.get (), "executable for", filename);
385398

386399
if (fd.get () >= 0)
387400
destname->reset (dname);

gdb/ui-out.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ class ui_out
302302

303303
~progress_update ()
304304
{
305-
305+
m_uiout->do_progress_end ();
306306
}
307307

308308
progress_update (const progress_update &) = delete;
@@ -321,14 +321,13 @@ class ui_out
321321
{
322322
m_uiout->do_progress_notify (msg, "", -1, -1);
323323
}
324+
324325
private:
325326

326327
struct ui_out *m_uiout;
327328
};
328329

329-
virtual void do_progress_end () = 0;
330-
331-
protected:
330+
protected:
332331

333332
virtual void do_table_begin (int nbrofcols, int nr_rows, const char *tblid)
334333
= 0;
@@ -365,6 +364,7 @@ class ui_out
365364
virtual void do_progress_start () = 0;
366365
virtual void do_progress_notify (const std::string &, const char *,
367366
double, double) = 0;
367+
virtual void do_progress_end () = 0;
368368

369369
/* Set as not MI-like by default. It is overridden in subclasses if
370370
necessary. */

0 commit comments

Comments
 (0)