[v7,03/10] Code cleanup: Rename enum -> enum filterflags

Message ID 20150614192606.18346.1038.stgit@host1.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil June 14, 2015, 7:26 p.m. UTC
  Hi Sergio,

this is an unrelated cleanup, bit mask ints are better to make enums as GDB
already has support to automatically decode them:

before this patch:
	(gdb) p filterflags
	$1 = 51
	(gdb) p/x filterflags
	$2 = 0x33

after this patch:
	(gdb) p filterflags
	$1 = (COREFILTER_ANON_PRIVATE | COREFILTER_ANON_SHARED | COREFILTER_ELF_HEADERS | COREFILTER_HUGETLB_PRIVATE)

New patch, not yet reviewed before.


Jan


gdb/ChangeLog
2015-06-07  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* linux-tdep.c (enum filterflags): Make it from anonymous enum.
	(dump_mapping_p): Use it for parameter filterflags.
	(linux_find_memory_regions_full): Use it for variable filterflags.
---
 gdb/linux-tdep.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
  

Comments

Joel Brobecker June 15, 2015, 1:34 p.m. UTC | #1
> gdb/ChangeLog
> 2015-06-07  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* linux-tdep.c (enum filterflags): Make it from anonymous enum.
> 	(dump_mapping_p): Use it for parameter filterflags.
> 	(linux_find_memory_regions_full): Use it for variable filterflags.

Would be OK with me, pending comments from Sergio.
  
Jan Kratochvil June 15, 2015, 3:12 p.m. UTC | #2
On Mon, 15 Jun 2015 15:34:06 +0200, Joel Brobecker wrote:
> > gdb/ChangeLog
> > 2015-06-07  Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 
> > 	* linux-tdep.c (enum filterflags): Make it from anonymous enum.
> > 	(dump_mapping_p): Use it for parameter filterflags.
> > 	(linux_find_memory_regions_full): Use it for variable filterflags.
> 
> Would be OK with me,

Checked in:
	31b7833d205031b52996982f5da025d60c6e052f


> pending comments from Sergio.

Sergio already expressed his agreement:
	https://sourceware.org/ml/gdb-patches/2015-06/msg00107.html


Jan
  
Pedro Alves July 8, 2015, 2:37 p.m. UTC | #3
On 06/14/2015 08:26 PM, Jan Kratochvil wrote:
> Hi Sergio,
> 
> this is an unrelated cleanup, bit mask ints are better to make enums as GDB
> already has support to automatically decode them:
> 
> before this patch:
> 	(gdb) p filterflags
> 	$1 = 51
> 	(gdb) p/x filterflags
> 	$2 = 0x33
> 
> after this patch:
> 	(gdb) p filterflags
> 	$1 = (COREFILTER_ANON_PRIVATE | COREFILTER_ANON_SHARED | COREFILTER_ELF_HEADERS | COREFILTER_HUGETLB_PRIVATE)
> 
> New patch, not yet reviewed before.

OK.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index f0cdc9c..c81f71b 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -46,7 +46,7 @@ 
    Documentation/filesystems/proc.txt, inside the Linux kernel
    tree.  */
 
-enum
+enum filterflags
   {
     COREFILTER_ANON_PRIVATE = 1 << 0,
     COREFILTER_ANON_SHARED = 1 << 1,
@@ -598,7 +598,7 @@  mapping_is_anonymous_p (const char *filename)
      This should work OK enough, however.  */
 
 static int
-dump_mapping_p (unsigned int filterflags, const struct smaps_vmflags *v,
+dump_mapping_p (enum filterflags filterflags, const struct smaps_vmflags *v,
 		int maybe_private_p, int mapping_anon_p, int mapping_file_p,
 		const char *filename)
 {
@@ -1119,10 +1119,10 @@  linux_find_memory_regions_full (struct gdbarch *gdbarch,
   /* Default dump behavior of coredump_filter (0x33), according to
      Documentation/filesystems/proc.txt from the Linux kernel
      tree.  */
-  unsigned int filterflags = (COREFILTER_ANON_PRIVATE
-			      | COREFILTER_ANON_SHARED
-			      | COREFILTER_ELF_HEADERS
-			      | COREFILTER_HUGETLB_PRIVATE);
+  enum filterflags filterflags = (COREFILTER_ANON_PRIVATE
+				  | COREFILTER_ANON_SHARED
+				  | COREFILTER_ELF_HEADERS
+				  | COREFILTER_HUGETLB_PRIVATE);
 
   /* We need to know the real target PID to access /proc.  */
   if (current_inferior ()->fake_pid_p)