diff options
author | Tom Tromey <tromey@adacore.com> | 2023-09-01 11:01:33 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-11-27 12:55:14 -0700 |
commit | 602971b3863dcecf2daa5ffc0853a75a3131446c (patch) | |
tree | e6965aecdcad64bf33e19a5927618a06be17d2a1 /gdb/windows-nat.c | |
parent | 4dda9cc4b03788d1cf0416b39a3ab3780caf27fd (diff) | |
download | binutils-602971b3863dcecf2daa5ffc0853a75a3131446c.zip binutils-602971b3863dcecf2daa5ffc0853a75a3131446c.tar.gz binutils-602971b3863dcecf2daa5ffc0853a75a3131446c.tar.bz2 |
Introduce throw_winerror_with_name
This introduces throw_winerror_with_name, a Windows analog of
perror_with_name, and changes various places in gdb to call it.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770
Diffstat (limited to 'gdb/windows-nat.c')
-rw-r--r-- | gdb/windows-nat.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index b344034..39a4e79 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1346,9 +1346,9 @@ windows_nat_target::windows_continue (DWORD continue_status, int id, }); if (err.has_value ()) - error (_("Failed to resume program execution" - " (ContinueDebugEvent failed, error %u: %s)"), - *err, strwinerror (*err)); + throw_winerror_with_name (_("Failed to resume program execution" + " - ContinueDebugEvent failed"), + *err); return TRUE; } @@ -1366,8 +1366,7 @@ windows_nat_target::fake_create_process () else { unsigned err = (unsigned) GetLastError (); - error (_("OpenProcess call failed, GetLastError = %u: %s"), - err, strwinerror (err)); + throw_winerror_with_name (_("OpenProcess call failed"), err); /* We can not debug anything in that case. */ } add_thread (ptid_t (windows_process.current_event.dwProcessId, 0, @@ -2047,8 +2046,11 @@ windows_nat_target::attach (const char *args, int from_tty) }); if (err.has_value ()) - error (_("Can't attach to process %u (error %u: %s)"), - (unsigned) pid, *err, strwinerror (*err)); + { + std::string msg = string_printf (_("Can't attach to process %u"), + (unsigned) pid); + throw_winerror_with_name (msg.c_str (), *err); + } DebugSetProcessKillOnExit (FALSE); @@ -2085,9 +2087,12 @@ windows_nat_target::detach (inferior *inf, int from_tty) }); if (err.has_value ()) - error (_("Can't detach process %u (error %u: %s)"), - (unsigned) windows_process.current_event.dwProcessId, - *err, strwinerror (*err)); + { + std::string msg + = string_printf (_("Can't detach process %u"), + (unsigned) windows_process.current_event.dwProcessId); + throw_winerror_with_name (msg.c_str (), *err); + } target_announce_detach (from_tty); @@ -2790,8 +2795,10 @@ windows_nat_target::create_inferior (const char *exec_file, #endif /* !__CYGWIN__ */ if (ret.has_value ()) - error (_("Error creating process %s, (error %u: %s)"), - exec_file, *ret, strwinerror (*ret)); + { + std::string msg = _("Error creating process ") + std::string (exec_file); + throw_winerror_with_name (msg.c_str (), *ret); + } #ifdef __x86_64__ BOOL wow64; |