File: utils.c

package info (click to toggle)
valgrind 1%3A3.12.0~svn20160714-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 120,428 kB
  • ctags: 70,855
  • sloc: ansic: 674,645; exp: 26,134; xml: 21,574; asm: 7,570; cpp: 7,567; makefile: 7,380; sh: 6,188; perl: 5,855; haskell: 195
file content (88 lines) | stat: -rw-r--r-- 2,597 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* General utility routines for the remote server for GDB.
   Copyright (C) 1986, 1989, 1993, 1995, 1996, 1997, 1999, 2000, 2002, 2003,
   2011
   Free Software Foundation, Inc.

   This file is part of GDB.
   It has been modified to integrate it in valgrind

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.  */

#include "server.h"
/* Generally useful subroutines used throughout the program.  */

/* Print the system error message for sr.
   Then print the rest of the args. */
void sr_perror (SysRes sr, const char *string,...)
{
   va_list args;
   if (sr_isError (sr))
      VG_(umsg) ("error %lu %s\n", sr_Err(sr), VG_(strerror) (sr_Err(sr)));
   else
      VG_(umsg) ("sr_perror called with no error!!!\n");
   va_start (args, string);
   VG_(vmessage) ( Vg_UserMsg, string, args );
   va_end (args);
}

/* Print an error message and return to command level.
   STRING is the error message, used as a fprintf string,
   and ARG is passed as an argument to it.  */

void error (const char *string,...)
{
   va_list args;
   va_start (args, string);
   VG_(vmessage) ( Vg_UserMsg, string, args );
   va_end(args);
   VG_MINIMAL_LONGJMP(toplevel);
}

/* Print an error message and exit reporting failure.
   This is for a error that we cannot continue from.
   STRING and ARG are passed to fprintf.  */

/* VARARGS */
void fatal (const char *string,...)
{
   va_list args;
   va_start (args, string);
   VG_(vmessage) ( Vg_UserMsg, string, args );
   va_end (args);
   VG_(exit) (1);
}

/* VARARGS */
void warning (const char *string,...)
{
   va_list args;
   va_start (args, string);
   VG_(vmessage) ( Vg_UserMsg, string, args );
   va_end (args);
}

#if 0
/* print timestamp */
static
void dbgts(void)
{
   struct vki_timeval dbgtv;
   SysRes res;
   res = VG_(do_syscall2)(__NR_gettimeofday, (UWord)&dbgtv, (UWord)NULL);
   // gettimeofday(&dbgtv, NULL);
   dlog(0, "%ld.%6ld ", dbgtv.tv_sec, dbgtv.tv_usec);
}
#endif