aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog9
-rw-r--r--gdb/gdbserver/debug.c16
-rw-r--r--gdb/gdbserver/tracepoint.c10
3 files changed, 20 insertions, 15 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 701e22e..8b83461 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,12 @@
+2016-11-23 Pedro Alves <palves@redhat.com>
+
+ * debug.c: Include <chrono> instead of "gdb_sys_time.h".
+ (debug_vprintf): Use std::chrono::steady_clock instead of
+ gettimeofday. Use '.' instead of ':'.
+ * tracepoint.c: Include <chrono> instead of "gdb_sys_time.h".
+ (get_timestamp): Use std::chrono::steady_clock instead of
+ gettimeofday.
+
2016-11-22 Simon Marchi <simon.marchi@polymtl.ca>
* Makefile.in: Fix whitespace formatting.
diff --git a/gdb/gdbserver/debug.c b/gdb/gdbserver/debug.c
index 54f2665..0e6a3a6 100644
--- a/gdb/gdbserver/debug.c
+++ b/gdb/gdbserver/debug.c
@@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "server.h"
-#include "gdb_sys_time.h"
+#include <chrono>
/* Enable miscellaneous debugging output. The name is historical - it
was originally used to debug LinuxThreads support. */
@@ -27,8 +27,7 @@ int debug_threads;
int debug_timestamp;
/* Print a debugging message.
- If the text begins a new line it is preceded by a timestamp, if the
- system has gettimeofday.
+ If the text begins a new line it is preceded by a timestamp.
We don't get fancy with newline checking, we just check whether the
previous call ended with "\n". */
@@ -41,14 +40,13 @@ debug_vprintf (const char *format, va_list ap)
if (debug_timestamp && new_line)
{
- struct timeval tm;
+ using namespace std::chrono;
- gettimeofday (&tm, NULL);
+ steady_clock::time_point now = steady_clock::now ();
+ seconds s = duration_cast<seconds> (now.time_since_epoch ());
+ microseconds us = duration_cast<microseconds> (now.time_since_epoch ()) - s;
- /* If gettimeofday doesn't exist, and as a portability solution it has
- been replaced with, e.g., time, then it doesn't make sense to print
- the microseconds field. Is there a way to check for that? */
- fprintf (stderr, "%ld:%06ld ", (long) tm.tv_sec, (long) tm.tv_usec);
+ fprintf (stderr, "%ld.%06ld ", (long) s.count (), (long) us.count ());
}
#endif
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 7700ad1..1444a0d 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -25,7 +25,7 @@
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
-#include "gdb_sys_time.h"
+#include <chrono>
#include <inttypes.h>
#include "ax.h"
#include "tdesc.h"
@@ -7410,12 +7410,10 @@ getauxval (unsigned long type)
static LONGEST
get_timestamp (void)
{
- struct timeval tv;
+ using namespace std::chrono;
- if (gettimeofday (&tv, 0) != 0)
- return -1;
- else
- return (LONGEST) tv.tv_sec * 1000000 + tv.tv_usec;
+ steady_clock::time_point now = steady_clock::now ();
+ return duration_cast<microseconds> (now.time_since_epoch ()).count ();
}
void