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/mips-tdep.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/mips-tdep.c')
-rw-r--r-- | gdb/mips-tdep.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index bd8faef..6e8ccd6 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -1345,14 +1345,13 @@ mips_in_frame_stub (CORE_ADDR pc) return 0; /* If the PC is in __mips16_call_stub_*, this is a call/return stub. */ - if (strncmp (name, mips_str_mips16_call_stub, - strlen (mips_str_mips16_call_stub)) == 0) + if (startswith (name, mips_str_mips16_call_stub)) return 1; /* If the PC is in __call_stub_*, this is a call/return or a call stub. */ - if (strncmp (name, mips_str_call_stub, strlen (mips_str_call_stub)) == 0) + if (startswith (name, mips_str_call_stub)) return 1; /* If the PC is in __fn_stub_*, this is a call stub. */ - if (strncmp (name, mips_str_fn_stub, strlen (mips_str_fn_stub)) == 0) + if (startswith (name, mips_str_fn_stub)) return 1; return 0; /* Not a stub. */ @@ -3813,7 +3812,7 @@ mips_stub_frame_sniffer (const struct frame_unwind *self, msym = lookup_minimal_symbol_by_pc (pc); if (msym.minsym != NULL && MSYMBOL_LINKAGE_NAME (msym.minsym) != NULL - && strncmp (MSYMBOL_LINKAGE_NAME (msym.minsym), ".pic.", 5) == 0) + && startswith (MSYMBOL_LINKAGE_NAME (msym.minsym), ".pic.")) return 1; return 0; @@ -7846,8 +7845,8 @@ mips_skip_mips16_trampoline_code (struct frame_info *frame, CORE_ADDR pc) /* If the PC is in __call_stub_* or __fn_stub*, this is one of the compiler-generated call or call/return stubs. */ - if (strncmp (name, mips_str_fn_stub, strlen (mips_str_fn_stub)) == 0 - || strncmp (name, mips_str_call_stub, strlen (mips_str_call_stub)) == 0) + if (startswith (name, mips_str_fn_stub) + || startswith (name, mips_str_call_stub)) { if (pc == start_addr) /* This is the 'call' part of a call stub. Call this helper @@ -7934,7 +7933,7 @@ mips_skip_pic_trampoline_code (struct frame_info *frame, CORE_ADDR pc) if (msym.minsym == NULL || BMSYMBOL_VALUE_ADDRESS (msym) != pc || MSYMBOL_LINKAGE_NAME (msym.minsym) == NULL - || strncmp (MSYMBOL_LINKAGE_NAME (msym.minsym), ".pic.", 5) != 0) + || !startswith (MSYMBOL_LINKAGE_NAME (msym.minsym), ".pic.")) return 0; /* A two-instruction header. */ @@ -8099,7 +8098,7 @@ mips_find_abi_section (bfd *abfd, asection *sect, void *obj) if (*abip != MIPS_ABI_UNKNOWN) return; - if (strncmp (name, ".mdebug.", 8) != 0) + if (!startswith (name, ".mdebug.")) return; if (strcmp (name, ".mdebug.abi32") == 0) @@ -8124,11 +8123,11 @@ mips_find_long_section (bfd *abfd, asection *sect, void *obj) int *lbp = (int *) obj; const char *name = bfd_get_section_name (abfd, sect); - if (strncmp (name, ".gcc_compiled_long32", 20) == 0) + if (startswith (name, ".gcc_compiled_long32")) *lbp = 32; - else if (strncmp (name, ".gcc_compiled_long64", 20) == 0) + else if (startswith (name, ".gcc_compiled_long64")) *lbp = 64; - else if (strncmp (name, ".gcc_compiled_long", 18) == 0) + else if (startswith (name, ".gcc_compiled_long")) warning (_("unrecognized .gcc_compiled_longXX")); } |