343902  --vgdb=yes doesn't break when --xml=yes is used

Changes ensures that gdbserver is called also when xml is yes.
When gdbserver is set to yes, we have to temporarily reset 
xml output to no, as gdbserver output (e.g. print the last error)
has to be printed to gdb.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15031 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/NEWS b/NEWS
index 6fd4415..f5e8adb 100644
--- a/NEWS
+++ b/NEWS
@@ -120,6 +120,7 @@
 343733  Unhandled syscall 187 (msgctl and related) on aarch64
 343802  s390x: Fix false positives "conditional jump or move depends on
         unitialised value(s)"
+343902  --vgdb=yes doesn't break when --xml=yes is used
 343967  Don't warn about setuid/setgid/setcap executable for directories
 343978  Recognize DWARF5/GCC5 DW_LANG_Fortran 2003 and 2008 constants
 344007  accept4 syscall unhandled on arm64 (242) and ppc64 (344)
diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c
index 6b59c8e..bcdd2a0 100644
--- a/coregrind/m_errormgr.c
+++ b/coregrind/m_errormgr.c
@@ -525,9 +525,6 @@
 {
    Bool still_noisy = True;
 
-   /* Should be assured by caller */
-   vg_assert( ! VG_(clo_xml) );
-
    /* if user wants to debug from a certain error nr, then wait for gdb/vgdb */
    if (VG_(clo_vgdb) != Vg_VgdbNo
        && allow_db_attach 
@@ -581,9 +578,8 @@
 
    * prints the tool-specific parts of the message
 
-   * calls do_actions_on_error.  This optionally does a debugger
-     attach (and detach), and optionally prints a suppression; both
-     of these may require user input.
+   * calls do_actions_on_error.  This optionally does a gdbserver call
+     and optionally prints a suppression; both of these may require user input.
 */
 static void pp_Error ( const Error* err, Bool allow_db_attach, Bool xml )
 {
@@ -593,8 +589,6 @@
 
    if (xml) {
 
-      /* Note, allow_db_attach is ignored in here. */
- 
       /* Ensure that suppression generation is either completely
          enabled or completely disabled; either way, we won't require
          any user input.  m_main.process_cmd_line_options should
@@ -646,8 +640,9 @@
       if (VG_(clo_error_markers)[1])
          VG_(umsg)("%s\n", VG_(clo_error_markers)[1]);
 
-      do_actions_on_error(err, allow_db_attach);
    }
+
+   do_actions_on_error(err, allow_db_attach);
 }
 
 
diff --git a/coregrind/m_gdbserver/server.c b/coregrind/m_gdbserver/server.c
index 9aae3a3..7de641f 100644
--- a/coregrind/m_gdbserver/server.c
+++ b/coregrind/m_gdbserver/server.c
@@ -308,7 +308,8 @@
          (*sink_wanted_at_return).fd = initial_valgrind_sink.fd;
          command_output_to_log = False;
          VG_(gdb_printf)
-            ("valgrind output will go to log, interactive output will go to gdb\n");
+            ("valgrind output will go to log, "
+             "interactive output will go to gdb\n");
          break;
       case 6: /* hostvisibility */
          wcmd = strtok_r (NULL, " ", &ssaveptr);
@@ -428,12 +429,13 @@
             GDB equivalent command of 'v.info location' is 'info symbol'. */
          Addr address;
          SizeT dummy_sz = 0x1234;
-         if (VG_(strtok_get_address_and_size) (&address, &dummy_sz, &ssaveptr)) {
+         if (VG_(strtok_get_address_and_size) (&address, 
+                                               &dummy_sz, &ssaveptr)) {
             // If tool provides location information, use that.
             if (VG_(needs).info_location) {
                VG_TDICT_CALL(tool_info_location, address);
             } 
-            // If tool does not provide location information, use the common one.
+            // If tool does not provide location info, use the common one.
             // Also use the common to compare with tool when debug log is set.
             if (!VG_(needs).info_location || VG_(debugLog_getLevel)() > 0 ) {
                AddrInfo ai;
@@ -544,6 +546,9 @@
    // one we have when entering. It can however be changed by the standard
    // valgrind command handling.
    OutputSink sink_wanted_at_return = VG_(log_output_sink);
+   // When using gdbserver, we temporarily disable xml output.
+   Bool save_clo_xml = VG_(clo_xml);
+   VG_(clo_xml) = False;
 
    if (!initial_valgrind_sink_saved) {
       /* first time we enter here, we save the valgrind default log sink */
@@ -580,6 +585,8 @@
 
    /* restore or set the desired output */
    VG_(log_output_sink).fd = sink_wanted_at_return.fd;
+   VG_(clo_xml) = save_clo_xml;
+
    if (ret | tool_ret)
       return 1;
    else