+ /* exec_file_attach and symbol_file_add_main may throw an error if the file
+ cannot be opened either locally or remotely.
+
+ This happens for example, when the file is first found in the local
+ sysroot (above), and then disappears (a TOCTOU race), or when it doesn't
+ exist in the target filesystem, or when the file does exist, but
+ is not readable.
+
+ Even without a symbol file, the remote-based debugging session should
+ continue normally instead of ending abruptly. Hence we catch thrown
+ errors/exceptions in the following code. */
+ try
+ {
+ /* We must do this step even if exec_file_host is NULL, so that
+ exec_file_attach will clear state. */
+ exec_file_attach (exec_file_host, add_flags & SYMFILE_VERBOSE);
+ }
+ catch (gdb_exception_error &err)
+ {
+ if (err.message != NULL)
+ warning ("%s", err.what ());
+
+ prev_err = std::move (err);
+ }
+
+ if (exec_file_host != NULL)
+ {
+ try
+ {
+ symbol_file_add_main (exec_file_host, add_flags);
+ }
+ catch (const gdb_exception_error &err)
+ {
+ if (!exception_print_same (prev_err, err))
+ warning ("%s", err.what ());
+ }
+ }