diff options
author | Gary Benson <gbenson@redhat.com> | 2015-03-06 09:42:06 +0000 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2015-03-06 09:42:06 +0000 |
commit | 61012eef8463764ccd9117dc1c9bc43cc452b7cc (patch) | |
tree | f576a77bcb77e71cc60e6592b56d2aa915b50c36 /gdb/tracefile-tfile.c | |
parent | e80417caef36c7d5e3d1da6a3b396a872d9d7201 (diff) | |
download | gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.zip gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.tar.gz gdb-61012eef8463764ccd9117dc1c9bc43cc452b7cc.tar.bz2 |
New common function "startswith"
This commit introduces a new inline common function "startswith"
which takes two string arguments and returns nonzero if the first
string starts with the second. It also updates the 295 places
where this logic was written out longhand to use the new function.
gdb/ChangeLog:
* common/common-utils.h (startswith): New inline function.
All places where this logic was used updated to use the above.
Diffstat (limited to 'gdb/tracefile-tfile.c')
-rw-r--r-- | gdb/tracefile-tfile.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index 44c6189..3ee7243 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -426,7 +426,7 @@ tfile_open (const char *arg, int from_tty) bytes += TRACE_HEADER_SIZE; if (!(header[0] == 0x7f - && (strncmp (header + 1, "TRACE0\n", 7) == 0))) + && (startswith (header + 1, "TRACE0\n")))) error (_("File is not a valid trace file.")); push_target (&tfile_ops); @@ -510,22 +510,22 @@ tfile_interp_line (char *line, struct uploaded_tp **utpp, { char *p = line; - if (strncmp (p, "R ", strlen ("R ")) == 0) + if (startswith (p, "R ")) { p += strlen ("R "); trace_regblock_size = strtol (p, &p, 16); } - else if (strncmp (p, "status ", strlen ("status ")) == 0) + else if (startswith (p, "status ")) { p += strlen ("status "); parse_trace_status (p, current_trace_status ()); } - else if (strncmp (p, "tp ", strlen ("tp ")) == 0) + else if (startswith (p, "tp ")) { p += strlen ("tp "); parse_tracepoint_definition (p, utpp); } - else if (strncmp (p, "tsv ", strlen ("tsv ")) == 0) + else if (startswith (p, "tsv ")) { p += strlen ("tsv "); parse_tsv_definition (p, utsvp); |