* [PATCH][PUSHED/OBV] gdb: Small cleanup to disasm.c:maybe_add_dis_line_entry
@ 2016-01-21 12:00 Andrew Burgess
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2016-01-21 12:00 UTC (permalink / raw)
To: gdb-patches; +Cc: Andrew Burgess
Give the function a better name (drop "maybe_") and update the header
comment.
gdb/ChangeLog:
* disasm.c (maybe_add_dis_line_entry): Rename to...
(add_dis_line_entry): ...this, and update header comment.
(do_mixed_source_and_assembly): Now use add_dis_line_entry.
---
gdb/ChangeLog | 6 ++++++
gdb/disasm.c | 7 +++----
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 68d10ad..45d8ef9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2016-01-21 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * disasm.c (maybe_add_dis_line_entry): Rename to...
+ (add_dis_line_entry): ...this, and update header comment.
+ (do_mixed_source_and_assembly): Now use add_dis_line_entry.
+
2016-01-21 Pedro Alves <palves@redhat.com>
* Makefile.in (COMPILER_CFLAGS): New.
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 9405928..1cf0901 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -86,11 +86,10 @@ allocate_dis_line_table (void)
xfree, xcalloc, xfree);
}
-/* Add DLE to TABLE.
- Returns 1 if added, 0 if already present. */
+/* Add a new dis_line_entry containing SYMTAB and LINE to TABLE. */
static void
-maybe_add_dis_line_entry (htab_t table, struct symtab *symtab, int line)
+add_dis_line_entry (htab_t table, struct symtab *symtab, int line)
{
void **slot;
struct dis_line_entry dle, *dlep;
@@ -552,7 +551,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
pc += length;
if (sal.symtab != NULL)
- maybe_add_dis_line_entry (dis_line_table, sal.symtab, sal.line);
+ add_dis_line_entry (dis_line_table, sal.symtab, sal.line);
}
/* Second pass: print the disassembly.
--
2.5.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][PUSHED/OBV] gdb: Small cleanup to disasm.c:maybe_add_dis_line_entry
@ 2016-01-21 21:48 Doug Evans
0 siblings, 0 replies; 2+ messages in thread
From: Doug Evans @ 2016-01-21 21:48 UTC (permalink / raw)
To: Andrew Burgess; +Cc: gdb-patches
Andrew Burgess writes:
> Give the function a better name (drop "maybe_") and update the header
> comment.
>
> gdb/ChangeLog:
>
> * disasm.c (maybe_add_dis_line_entry): Rename to...
> (add_dis_line_entry): ...this, and update header comment.
> (do_mixed_source_and_assembly): Now use add_dis_line_entry.
> ---
> gdb/ChangeLog | 6 ++++++
> gdb/disasm.c | 7 +++----
> 2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 68d10ad..45d8ef9 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,9 @@
> +2016-01-21 Andrew Burgess <andrew.burgess@embecosm.com>
> +
> + * disasm.c (maybe_add_dis_line_entry): Rename to...
> + (add_dis_line_entry): ...this, and update header comment.
> + (do_mixed_source_and_assembly): Now use add_dis_line_entry.
> +
> 2016-01-21 Pedro Alves <palves@redhat.com>
>
> * Makefile.in (COMPILER_CFLAGS): New.
> diff --git a/gdb/disasm.c b/gdb/disasm.c
> index 9405928..1cf0901 100644
> --- a/gdb/disasm.c
> +++ b/gdb/disasm.c
> @@ -86,11 +86,10 @@ allocate_dis_line_table (void)
> xfree, xcalloc, xfree);
> }
>
> -/* Add DLE to TABLE.
> - Returns 1 if added, 0 if already present. */
> +/* Add a new dis_line_entry containing SYMTAB and LINE to TABLE. */
>
> static void
> -maybe_add_dis_line_entry (htab_t table, struct symtab *symtab, int line)
> +add_dis_line_entry (htab_t table, struct symtab *symtab, int line)
> {
> void **slot;
> struct dis_line_entry dle, *dlep;
> @@ -552,7 +551,7 @@ do_mixed_source_and_assembly (struct gdbarch
*gdbarch, struct ui_out *uiout,
> pc += length;
>
> if (sal.symtab != NULL)
> - maybe_add_dis_line_entry (dis_line_table, sal.symtab, sal.line);
> + add_dis_line_entry (dis_line_table, sal.symtab, sal.line);
> }
>
> /* Second pass: print the disassembly.
Hi.
For reference sake,
I *like* the "maybe" as the new function name is wrong.
Here is the function:
static void
add_dis_line_entry (htab_t table, struct symtab *symtab, int line)
{
void **slot;
struct dis_line_entry dle, *dlep;
dle.symtab = symtab;
dle.line = line;
slot = htab_find_slot (table, &dle, INSERT);
if (*slot == NULL)
{
dlep = XNEW (struct dis_line_entry);
dlep->symtab = symtab;
dlep->line = line;
*slot = dlep;
}
}
The entry is only added if it is not already present.
"add_dis_line_entry" implies, to this reader,
that it is *always* added which is obviously wrong.
Heads up, I may change it back.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-21 21:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-21 12:00 [PATCH][PUSHED/OBV] gdb: Small cleanup to disasm.c:maybe_add_dis_line_entry Andrew Burgess
2016-01-21 21:48 Doug Evans
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).