Home | History | Annotate | Download | only in m_gdbserver
      1 /* General utility routines for the remote server for GDB.
      2    Copyright (C) 1986, 1989, 1993, 1995, 1996, 1997, 1999, 2000, 2002, 2003,
      3    2011
      4    Free Software Foundation, Inc.
      5 
      6    This file is part of GDB.
      7    It has been modified to integrate it in valgrind
      8 
      9    This program is free software; you can redistribute it and/or modify
     10    it under the terms of the GNU General Public License as published by
     11    the Free Software Foundation; either version 2 of the License, or
     12    (at your option) any later version.
     13 
     14    This program is distributed in the hope that it will be useful,
     15    but WITHOUT ANY WARRANTY; without even the implied warranty of
     16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17    GNU General Public License for more details.
     18 
     19    You should have received a copy of the GNU General Public License
     20    along with this program; if not, write to the Free Software
     21    Foundation, Inc., 51 Franklin Street, Fifth Floor,
     22    Boston, MA 02110-1301, USA.  */
     23 
     24 #include "server.h"
     25 /* Generally useful subroutines used throughout the program.  */
     26 
     27 /* Print the system error message for sr.
     28    Then print the rest of the args. */
     29 void sr_perror (SysRes sr, const char *string,...)
     30 {
     31    va_list args;
     32    if (sr_isError (sr))
     33       VG_(umsg) ("error %lu %s\n", sr_Err(sr), VG_(strerror) (sr_Err(sr)));
     34    else
     35       VG_(umsg) ("sr_perror called with no error!!!\n");
     36    va_start (args, string);
     37    VG_(vmessage) ( Vg_UserMsg, string, args );
     38    va_end (args);
     39 }
     40 
     41 /* Print an error message and return to command level.
     42    STRING is the error message, used as a fprintf string,
     43    and ARG is passed as an argument to it.  */
     44 
     45 void error (const char *string,...)
     46 {
     47    va_list args;
     48    va_start (args, string);
     49    VG_(vmessage) ( Vg_UserMsg, string, args );
     50    va_end(args);
     51    VG_MINIMAL_LONGJMP(toplevel);
     52 }
     53 
     54 /* Print an error message and exit reporting failure.
     55    This is for a error that we cannot continue from.
     56    STRING and ARG are passed to fprintf.  */
     57 
     58 /* VARARGS */
     59 void fatal (const char *string,...)
     60 {
     61    va_list args;
     62    va_start (args, string);
     63    VG_(vmessage) ( Vg_UserMsg, string, args );
     64    va_end (args);
     65    VG_(exit) (1);
     66 }
     67 
     68 /* VARARGS */
     69 void warning (const char *string,...)
     70 {
     71    va_list args;
     72    va_start (args, string);
     73    VG_(vmessage) ( Vg_UserMsg, string, args );
     74    va_end (args);
     75 }
     76 
     77 #if 0
     78 /* print timestamp */
     79 static
     80 void dbgts(void)
     81 {
     82    struct vki_timeval dbgtv;
     83    SysRes res;
     84    res = VG_(do_syscall2)(__NR_gettimeofday, (UWord)&dbgtv, (UWord)NULL);
     85    // gettimeofday(&dbgtv, NULL);
     86    dlog(0, "%ld.%6ld ", dbgtv.tv_sec, dbgtv.tv_usec);
     87 }
     88 #endif
     89