* [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter @ 2016-01-19 4:23 Simon Marchi 2016-01-19 4:23 ` [PATCH 2/2] Fix enum flag with Python 3 Simon Marchi 2016-01-19 11:02 ` [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter Pedro Alves 0 siblings, 2 replies; 9+ messages in thread From: Simon Marchi @ 2016-01-19 4:23 UTC (permalink / raw) To: gdb-patches; +Cc: Simon Marchi The lambda function used to sort the enumerator list does not work properly. This list consists of tuples, (enum label, enum value). The key function returns x.enumval. enumval not being defined for a tuple, we see this exception in the test log: Python Exception <class 'AttributeError'> 'tuple' object has no attribute 'enumval' The function should return the second item of the tuple, which is the enumval. The pretty-printer still worked mostly correctly, except that the enumeration values were not sorted. The test still passed because the enumeration values are already sorted where they are defined. The test also passed despite the exception being printed, because the right output was printed after the exception: print (enum flag_enum) (FLAG_1) Python Exception <type 'exceptions.AttributeError'> 'tuple' objecthas no attribute 'enumval':M $7 = 0x1 [FLAG_1] (gdb) PASS: gdb.python/py-pp-maint.exp: print FLAG_1 To properly test the sorting, I changed the order in which the enumeration values are defined. gdb/ChangeLog: * python/lib/gdb/printing.py (FlagEnumerationPrinter.__call__): Fix enumerators sort key function. gdb/testsuite/ChangeLog: * gdb.python/py-pp-main.c (enum flag_enum): Change enum values definition order. --- gdb/python/lib/gdb/printing.py | 2 +- gdb/testsuite/gdb.python/py-pp-maint.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py index 263d3ba..0b4a152 100644 --- a/gdb/python/lib/gdb/printing.py +++ b/gdb/python/lib/gdb/printing.py @@ -263,7 +263,7 @@ class FlagEnumerationPrinter(PrettyPrinter): self.enumerators.append((field.name, field.enumval)) # Sorting the enumerators by value usually does the right # thing. - self.enumerators.sort(key = lambda x: x.enumval) + self.enumerators.sort(key = lambda x: x[1]) if self.enabled: return _EnumInstance(self.enumerators, val) diff --git a/gdb/testsuite/gdb.python/py-pp-maint.c b/gdb/testsuite/gdb.python/py-pp-maint.c index 657dfd7..dc282e9 100644 --- a/gdb/testsuite/gdb.python/py-pp-maint.c +++ b/gdb/testsuite/gdb.python/py-pp-maint.c @@ -17,11 +17,14 @@ #include <string.h> + enum flag_enum { - FLAG_1 = 1, + /* Define the enumration values in an unsorted manner to verify that we + effectively sort them by value. */ FLAG_2 = 2, FLAG_3 = 4, + FLAG_1 = 1, ALL = FLAG_1 | FLAG_2 | FLAG_3 }; -- 2.7.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] Fix enum flag with Python 3 2016-01-19 4:23 [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter Simon Marchi @ 2016-01-19 4:23 ` Simon Marchi 2016-01-19 11:03 ` Pedro Alves 2016-01-19 11:02 ` [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter Pedro Alves 1 sibling, 1 reply; 9+ messages in thread From: Simon Marchi @ 2016-01-19 4:23 UTC (permalink / raw) To: gdb-patches; +Cc: Simon Marchi Using Python 3.5 (I assume it's the same with 3.4 and lower, but I didn't test), I see this: print (enum flag_enum) (FLAG_1)^M Python Exception <class 'TypeError'> %x format: an integer is required, not gdb.Value: ^M $7 = ^M (gdb) FAIL: gdb.python/py-pp-maint.exp: print FLAG_1 Apparently, this idiom, where v is a gdb.Value, was possible with Python 2, but not with Python 3: '%x' % v In Python 2, it would automatically get converted to an integer. To solve it, I simply added wrapped v in a call to int(). '%x' % int(v) In Python 2, the int type is implemented with a "long" in C, so on x86-32 it's 32-bits. I was worried that doing int(v) would truncate the value and give wrong results for enum values > 32-bits. However, the int type != the int function. The int function does the right thing, selecting the right integer type for the given value. I tested with large enum values on x86-32 and Python 2, and everything works as expected. gdb/ChangeLog: * python/lib/gdb/printing.py (_EnumInstance.to_string): Explicitly convert gdb.Value to integer type using int(). --- gdb/python/lib/gdb/printing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py index 0b4a152..63c3aeb 100644 --- a/gdb/python/lib/gdb/printing.py +++ b/gdb/python/lib/gdb/printing.py @@ -239,7 +239,7 @@ class _EnumInstance: if not any_found or v != 0: # Leftover value. flag_list.append('<unknown: 0x%x>' % v) - return "0x%x [%s]" % (self.val, " | ".join(flag_list)) + return "0x%x [%s]" % (int(self.val), " | ".join(flag_list)) class FlagEnumerationPrinter(PrettyPrinter): """A pretty-printer which can be used to print a flag-style enumeration. -- 2.7.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Fix enum flag with Python 3 2016-01-19 4:23 ` [PATCH 2/2] Fix enum flag with Python 3 Simon Marchi @ 2016-01-19 11:03 ` Pedro Alves 2016-01-19 16:08 ` Simon Marchi 0 siblings, 1 reply; 9+ messages in thread From: Pedro Alves @ 2016-01-19 11:03 UTC (permalink / raw) To: Simon Marchi, gdb-patches On 01/19/2016 04:23 AM, Simon Marchi wrote: > gdb/ChangeLog: > > * python/lib/gdb/printing.py (_EnumInstance.to_string): Explicitly > convert gdb.Value to integer type using int(). LGTM. Thanks, Pedro Alves ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Fix enum flag with Python 3 2016-01-19 11:03 ` Pedro Alves @ 2016-01-19 16:08 ` Simon Marchi 0 siblings, 0 replies; 9+ messages in thread From: Simon Marchi @ 2016-01-19 16:08 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches On 2016-01-19 06:03, Pedro Alves wrote: > On 01/19/2016 04:23 AM, Simon Marchi wrote: > >> gdb/ChangeLog: >> >> * python/lib/gdb/printing.py (_EnumInstance.to_string): Explicitly >> convert gdb.Value to integer type using int(). > > LGTM. Thanks, pushed! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter 2016-01-19 4:23 [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter Simon Marchi 2016-01-19 4:23 ` [PATCH 2/2] Fix enum flag with Python 3 Simon Marchi @ 2016-01-19 11:02 ` Pedro Alves 2016-01-19 16:41 ` Simon Marchi 1 sibling, 1 reply; 9+ messages in thread From: Pedro Alves @ 2016-01-19 11:02 UTC (permalink / raw) To: Simon Marchi, gdb-patches Thanks for catching this. I find it surprising that the printer doesn't respect the order of the values as they're defined though. Shouldn't we remove the sort line entirely, thus keeping the existing behavior? I couldn't find mention of the sorting in the documentation either. Or, maybe the printer doesn't work correctly if the "overlapping" value (which I think it the whole point of this printer) is defined before the particular values, like, e.g.: enum flag_enum { ALL = 1 | 2 | 4, FLAG_2 = 2, FLAG_3 = 4, FLAG_1 = 1, }; ? On 01/19/2016 04:23 AM, Simon Marchi wrote: > + > enum flag_enum > { > - FLAG_1 = 1, > + /* Define the enumration values in an unsorted manner to verify that we > + effectively sort them by value. */ typo: "enumration". Thanks, Pedro Alves ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter 2016-01-19 11:02 ` [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter Pedro Alves @ 2016-01-19 16:41 ` Simon Marchi 2016-01-20 14:41 ` Pedro Alves 0 siblings, 1 reply; 9+ messages in thread From: Simon Marchi @ 2016-01-19 16:41 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches On 2016-01-19 06:02, Pedro Alves wrote: > Thanks for catching this. > > I find it surprising that the printer doesn't respect the > order of the values as they're defined though. Shouldn't we > remove the sort line entirely, thus keeping the > existing behavior? I couldn't find mention of the sorting > in the documentation either. > > Or, maybe the printer doesn't work correctly if the "overlapping" > value (which I think it the whole point of this printer) is defined > before the particular values, like, e.g.: > > enum flag_enum > { > ALL = 1 | 2 | 4, > FLAG_2 = 2, > FLAG_3 = 4, > FLAG_1 = 1, > }; > > ? If we don't sort the values and ALL is defined first, then 0x7 will be displayed as ALL instead of FLAG_1 | FLAG_2 | FLAG_3. I don't think either is wrong, we just don't know which one each particular user would prefer. So I think we can choose one way (sorted order, or definition order) and stick with it. Personally, I think I would prefer the more explicit version (FLAG_1 | FLAG_2 | FLAG_3), which means keeping the sort. > On 01/19/2016 04:23 AM, Simon Marchi wrote: > >> + >> enum flag_enum >> { >> - FLAG_1 = 1, >> + /* Define the enumration values in an unsorted manner to verify >> that we >> + effectively sort them by value. */ > > typo: "enumration". Fixed. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter 2016-01-19 16:41 ` Simon Marchi @ 2016-01-20 14:41 ` Pedro Alves 2016-01-20 18:03 ` Simon Marchi 0 siblings, 1 reply; 9+ messages in thread From: Pedro Alves @ 2016-01-20 14:41 UTC (permalink / raw) To: Simon Marchi; +Cc: gdb-patches On 01/19/2016 04:41 PM, Simon Marchi wrote: > On 2016-01-19 06:02, Pedro Alves wrote: >> Thanks for catching this. >> >> I find it surprising that the printer doesn't respect the >> order of the values as they're defined though. Shouldn't we >> remove the sort line entirely, thus keeping the >> existing behavior? I couldn't find mention of the sorting >> in the documentation either. >> >> Or, maybe the printer doesn't work correctly if the "overlapping" >> value (which I think it the whole point of this printer) is defined >> before the particular values, like, e.g.: >> >> enum flag_enum >> { >> ALL = 1 | 2 | 4, >> FLAG_2 = 2, >> FLAG_3 = 4, >> FLAG_1 = 1, >> }; >> >> ? > > If we don't sort the values and ALL is defined first, then 0x7 will be > displayed as ALL instead of FLAG_1 | FLAG_2 | FLAG_3. I don't think > either is wrong, we just don't know which one each particular user > would prefer. So I think we can choose one way (sorted order, or > definition order) and stick with it. > > Personally, I think I would prefer the more explicit version > (FLAG_1 | FLAG_2 | FLAG_3), which means keeping the sort. OK, I think that makes sense for cases like: enum flag_enum { FOO_MASK = 0x07, FOO_1 = 0x01, FOO_2 = 0x02, FOO_3 = 0x04, BAR_MASK = 0x70, BAR_1 = 0x10, BAR_2 = 0x20, BAR_3 = x040, }; Would you mind augmenting the testsuite with something like this, then? Thanks, Pedro Alves ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter 2016-01-20 14:41 ` Pedro Alves @ 2016-01-20 18:03 ` Simon Marchi 2016-01-20 18:12 ` Simon Marchi 0 siblings, 1 reply; 9+ messages in thread From: Simon Marchi @ 2016-01-20 18:03 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches On 2016-01-20 09:41, Pedro Alves wrote: > OK, I think that makes sense for cases like: > > enum flag_enum > { > FOO_MASK = 0x07, > FOO_1 = 0x01, > FOO_2 = 0x02, > FOO_3 = 0x04, > > BAR_MASK = 0x70, > BAR_1 = 0x10, > BAR_2 = 0x20, > BAR_3 = x040, > }; > > Would you mind augmenting the testsuite with something > like this, then? > > Thanks, > Pedro Alves Here is a v2: From 5d7a3227fa50594c1f5541550a07481583e027df Mon Sep 17 00:00:00 2001 From: Simon Marchi <simon.marchi@polymtl.ca> Date: Mon, 18 Jan 2016 21:35:18 -0500 Subject: [PATCH] Fix sorting of enum values in FlagEnumerationPrinter The lambda function used to sort the enumerator list does not work properly. This list consists of tuples, (enum label, enum value). The key function returns x.enumval. enumval not being defined for a tuple, we see this exception in the test log: Python Exception <class 'AttributeError'> 'tuple' object has no attribute 'enumval' The function should return the second item of the tuple, which is the enumval. The pretty-printer still worked mostly correctly, except that the enumeration values were not sorted. The test still passed because the enumeration values are already sorted where they are defined. The test also passed despite the exception being printed, because the right output was printed after the exception: print (enum flag_enum) (FLAG_1) Python Exception <type 'exceptions.AttributeError'> 'tuple' objecthas no attribute 'enumval':M $7 = 0x1 [FLAG_1] (gdb) PASS: gdb.python/py-pp-maint.exp: print FLAG_1 New in v2: - Improved test case, I stole Pedro's example directly. It verifies that the sorting of enumerators by value works, by checking that printing FOO_MASK appears as FOO_1 | FOO_2 | FOO_3. I noticed that I could change the regexps to almost anything and the tests would still pass. I think it was because of the | in there. I made them more robust by using string_to_regexp. I used curly braces { } instead of quoting marks " " for strings, so that I could use square brackets [ ] in them without having to escape them all. I also removed the "message" part of the tests, since they are redundant with the command, and it's just more maintenance to have to update them. Tested with Python 2.7 and 3.5. gdb/ChangeLog: * python/lib/gdb/printing.py (FlagEnumerationPrinter.__call__): Fix enumerators sort key function. gdb/testsuite/ChangeLog: * gdb.python/py-pp-maint.exp: Change/add enum flag tests. * gdb.python/py-pp-maint.c (enum flag_enum): Use more complex enum flag values. --- gdb/python/lib/gdb/printing.py | 2 +- gdb/testsuite/gdb.python/py-pp-maint.c | 16 ++++++++++++---- gdb/testsuite/gdb.python/py-pp-maint.exp | 27 ++++++++++++++++++--------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py index 5160581..63c3aeb 100644 --- a/gdb/python/lib/gdb/printing.py +++ b/gdb/python/lib/gdb/printing.py @@ -263,7 +263,7 @@ class FlagEnumerationPrinter(PrettyPrinter): self.enumerators.append((field.name, field.enumval)) # Sorting the enumerators by value usually does the right # thing. - self.enumerators.sort(key = lambda x: x.enumval) + self.enumerators.sort(key = lambda x: x[1]) if self.enabled: return _EnumInstance(self.enumerators, val) diff --git a/gdb/testsuite/gdb.python/py-pp-maint.c b/gdb/testsuite/gdb.python/py-pp-maint.c index 657dfd7..d750496 100644 --- a/gdb/testsuite/gdb.python/py-pp-maint.c +++ b/gdb/testsuite/gdb.python/py-pp-maint.c @@ -17,12 +17,20 @@ #include <string.h> + enum flag_enum { - FLAG_1 = 1, - FLAG_2 = 2, - FLAG_3 = 4, - ALL = FLAG_1 | FLAG_2 | FLAG_3 + /* Define the enumeration values in an unsorted manner to verify that we + effectively sort them by value. */ + FOO_MASK = 0x07, + FOO_1 = 0x01, + FOO_2 = 0x02, + FOO_3 = 0x04, + + BAR_MASK = 0x70, + BAR_1 = 0x10, + BAR_2 = 0x20, + BAR_3 = 0x40, }; enum flag_enum fval; diff --git a/gdb/testsuite/gdb.python/py-pp-maint.exp b/gdb/testsuite/gdb.python/py-pp-maint.exp index db0768f..9dbe19f 100644 --- a/gdb/testsuite/gdb.python/py-pp-maint.exp +++ b/gdb/testsuite/gdb.python/py-pp-maint.exp @@ -119,14 +119,23 @@ gdb_test "print flt" " = x=<42> y=<43>" \ gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ "print ss re-enabled" -gdb_test "print (enum flag_enum) (FLAG_1)" \ - " = 0x1 .FLAG_1." \ - "print FLAG_1" +gdb_test "print (enum flag_enum) (FOO_1)" \ + [string_to_regexp { = 0x1 [FOO_1]}] -gdb_test "print (enum flag_enum) (FLAG_1 | FLAG_3)" \ - " = 0x5 .FLAG_1 | FLAG_3." \ - "print FLAG_1 | FLAG_3" +gdb_test "print (enum flag_enum) (BAR_3)" \ + [string_to_regexp { = 0x40 [BAR_3]}] -gdb_test "print (enum flag_enum) (4 + 8)" \ - " = 0xc .FLAG_1 | <unknown: 0x8>." \ - "print FLAG_1 | 8" +gdb_test "print (enum flag_enum) (BAR_2 | FOO_2)" \ + [string_to_regexp { = 0x22 [FOO_2 | BAR_2]}] + +gdb_test "print (enum flag_enum) (FOO_1 | FOO_2 | FOO_3)" \ + [string_to_regexp { = 0x7 [FOO_1 | FOO_2 | FOO_3]}] + +gdb_test "print (enum flag_enum) (FOO_MASK)" \ + [string_to_regexp { = 0x7 [FOO_1 | FOO_2 | FOO_3]}] + +gdb_test "print (enum flag_enum) (FOO_MASK | (BAR_MASK & ~BAR_2))" \ + [string_to_regexp { = 0x57 [FOO_1 | FOO_2 | FOO_3 | BAR_1 | BAR_3]}] + +gdb_test "print (enum flag_enum) (0x4 + 0x8)" \ + [string_to_regexp { = 0xc [FOO_3 | <unknown: 0x8>]}] -- 2.7.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter 2016-01-20 18:03 ` Simon Marchi @ 2016-01-20 18:12 ` Simon Marchi 0 siblings, 0 replies; 9+ messages in thread From: Simon Marchi @ 2016-01-20 18:12 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches On 2016-01-20 13:03, Simon Marchi wrote: > On 2016-01-20 09:41, Pedro Alves wrote: >> OK, I think that makes sense for cases like: >> >> enum flag_enum >> { >> FOO_MASK = 0x07, >> FOO_1 = 0x01, >> FOO_2 = 0x02, >> FOO_3 = 0x04, >> >> BAR_MASK = 0x70, >> BAR_1 = 0x10, >> BAR_2 = 0x20, >> BAR_3 = x040, >> }; >> >> Would you mind augmenting the testsuite with something >> like this, then? >> >> Thanks, >> Pedro Alves > > Here is a v2: > > > From 5d7a3227fa50594c1f5541550a07481583e027df Mon Sep 17 00:00:00 2001 > From: Simon Marchi <simon.marchi@polymtl.ca> > Date: Mon, 18 Jan 2016 21:35:18 -0500 > Subject: [PATCH] Fix sorting of enum values in FlagEnumerationPrinter > > The lambda function used to sort the enumerator list does not work > properly. This list consists of tuples, (enum label, enum value). The > key function returns x.enumval. enumval not being defined for a tuple, > we see this exception in the test log: > > Python Exception <class 'AttributeError'> 'tuple' object has no > attribute 'enumval' > > The function should return the second item of the tuple, which is the > enumval. > > The pretty-printer still worked mostly correctly, except that the > enumeration values were not sorted. The test still passed because the > enumeration values are already sorted where they are defined. The test > also passed despite the exception being printed, because the right > output > was printed after the exception: > > print (enum flag_enum) (FLAG_1) > Python Exception <type 'exceptions.AttributeError'> 'tuple' > objecthas no attribute 'enumval':M > $7 = 0x1 [FLAG_1] > (gdb) PASS: gdb.python/py-pp-maint.exp: print FLAG_1 > > New in v2: > > - Improved test case, I stole Pedro's example directly. It verifies > that the sorting of enumerators by value works, by checking that > printing FOO_MASK appears as FOO_1 | FOO_2 | FOO_3. > > I noticed that I could change the regexps to almost anything and the > tests would still pass. I think it was because of the | in there. I > made them more robust by using string_to_regexp. I used curly braces > { } instead of quoting marks " " for strings, so that I could use > square brackets [ ] in them without having to escape them all. I > also > removed the "message" part of the tests, since they are redundant > with > the command, and it's just more maintenance to have to update them. > > Tested with Python 2.7 and 3.5. > > gdb/ChangeLog: > > * python/lib/gdb/printing.py (FlagEnumerationPrinter.__call__): > Fix enumerators sort key function. > > gdb/testsuite/ChangeLog: > > * gdb.python/py-pp-maint.exp: Change/add enum flag tests. > * gdb.python/py-pp-maint.c (enum flag_enum): Use more complex > enum flag values. > --- > gdb/python/lib/gdb/printing.py | 2 +- > gdb/testsuite/gdb.python/py-pp-maint.c | 16 ++++++++++++---- > gdb/testsuite/gdb.python/py-pp-maint.exp | 27 > ++++++++++++++++++--------- > 3 files changed, 31 insertions(+), 14 deletions(-) > > diff --git a/gdb/python/lib/gdb/printing.py > b/gdb/python/lib/gdb/printing.py > index 5160581..63c3aeb 100644 > --- a/gdb/python/lib/gdb/printing.py > +++ b/gdb/python/lib/gdb/printing.py > @@ -263,7 +263,7 @@ class FlagEnumerationPrinter(PrettyPrinter): > self.enumerators.append((field.name, field.enumval)) > # Sorting the enumerators by value usually does the right > # thing. > - self.enumerators.sort(key = lambda x: x.enumval) > + self.enumerators.sort(key = lambda x: x[1]) > > if self.enabled: > return _EnumInstance(self.enumerators, val) > diff --git a/gdb/testsuite/gdb.python/py-pp-maint.c > b/gdb/testsuite/gdb.python/py-pp-maint.c > index 657dfd7..d750496 100644 > --- a/gdb/testsuite/gdb.python/py-pp-maint.c > +++ b/gdb/testsuite/gdb.python/py-pp-maint.c > @@ -17,12 +17,20 @@ > > #include <string.h> > > + > enum flag_enum > { > - FLAG_1 = 1, > - FLAG_2 = 2, > - FLAG_3 = 4, > - ALL = FLAG_1 | FLAG_2 | FLAG_3 > + /* Define the enumeration values in an unsorted manner to verify > that we > + effectively sort them by value. */ > + FOO_MASK = 0x07, > + FOO_1 = 0x01, > + FOO_2 = 0x02, > + FOO_3 = 0x04, > + > + BAR_MASK = 0x70, > + BAR_1 = 0x10, > + BAR_2 = 0x20, > + BAR_3 = 0x40, > }; > > enum flag_enum fval; > diff --git a/gdb/testsuite/gdb.python/py-pp-maint.exp > b/gdb/testsuite/gdb.python/py-pp-maint.exp > index db0768f..9dbe19f 100644 > --- a/gdb/testsuite/gdb.python/py-pp-maint.exp > +++ b/gdb/testsuite/gdb.python/py-pp-maint.exp > @@ -119,14 +119,23 @@ gdb_test "print flt" " = x=<42> y=<43>" \ > gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ > "print ss re-enabled" > > -gdb_test "print (enum flag_enum) (FLAG_1)" \ > - " = 0x1 .FLAG_1." \ > - "print FLAG_1" > +gdb_test "print (enum flag_enum) (FOO_1)" \ > + [string_to_regexp { = 0x1 [FOO_1]}] > > -gdb_test "print (enum flag_enum) (FLAG_1 | FLAG_3)" \ > - " = 0x5 .FLAG_1 | FLAG_3." \ > - "print FLAG_1 | FLAG_3" > +gdb_test "print (enum flag_enum) (BAR_3)" \ > + [string_to_regexp { = 0x40 [BAR_3]}] > > -gdb_test "print (enum flag_enum) (4 + 8)" \ > - " = 0xc .FLAG_1 | <unknown: 0x8>." \ > - "print FLAG_1 | 8" > +gdb_test "print (enum flag_enum) (BAR_2 | FOO_2)" \ > + [string_to_regexp { = 0x22 [FOO_2 | BAR_2]}] > + > +gdb_test "print (enum flag_enum) (FOO_1 | FOO_2 | FOO_3)" \ > + [string_to_regexp { = 0x7 [FOO_1 | FOO_2 | FOO_3]}] > + > +gdb_test "print (enum flag_enum) (FOO_MASK)" \ > + [string_to_regexp { = 0x7 [FOO_1 | FOO_2 | FOO_3]}] > + > +gdb_test "print (enum flag_enum) (FOO_MASK | (BAR_MASK & ~BAR_2))" \ > + [string_to_regexp { = 0x57 [FOO_1 | FOO_2 | FOO_3 | BAR_1 | > BAR_3]}] > + > +gdb_test "print (enum flag_enum) (0x4 + 0x8)" \ > + [string_to_regexp { = 0xc [FOO_3 | <unknown: 0x8>]}] I tried to apply my patch from here, and it says it's corrupt (I was using a web mail client). Please look at this version sent with git send-email instead. https://sourceware.org/ml/gdb-patches/2016-01/msg00485.html Thanks, Simon ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-01-20 18:12 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-01-19 4:23 [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter Simon Marchi 2016-01-19 4:23 ` [PATCH 2/2] Fix enum flag with Python 3 Simon Marchi 2016-01-19 11:03 ` Pedro Alves 2016-01-19 16:08 ` Simon Marchi 2016-01-19 11:02 ` [PATCH 1/2] Fix sorting of enum values in FlagEnumerationPrinter Pedro Alves 2016-01-19 16:41 ` Simon Marchi 2016-01-20 14:41 ` Pedro Alves 2016-01-20 18:03 ` Simon Marchi 2016-01-20 18:12 ` Simon Marchi
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).