binutils-gdb/gdb/testsuite/gdb.python
Simon Marchi 5f5dfff63f 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.
2016-01-20 13:44:33 -05:00
..
amd64-py-framefilter-invalidarg.S GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
lib-types.cc GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
lib-types.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
Makefile.in
py-arch.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-arch.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-bad-printers.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-bad-printers.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-bad-printers.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-block.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-block.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-breakpoint.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-breakpoint.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-caller-is.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-caller-is.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-cmd.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-cmd.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-completion.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-completion.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-error.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-error.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-events-shlib.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-events.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-events.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-events.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-evsignal.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-evthreads.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-evthreads.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-explore-cc.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-explore.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-explore.cc GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-explore.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-finish-breakpoint2.cc GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-finish-breakpoint2.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-finish-breakpoint2.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-finish-breakpoint.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-finish-breakpoint.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-finish-breakpoint.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-frame-args.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-frame-args.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-frame-args.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-frame-inline.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-frame-inline.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-frame.c
py-frame.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-framefilter-gdb.py.in GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-framefilter-invalidarg-gdb.py.in GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-framefilter-invalidarg.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-framefilter-invalidarg.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-framefilter-mi.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-framefilter-mi.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-framefilter.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-framefilter.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-framefilter.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-function.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-inferior.c
py-inferior.exp Reapply: List inferiors/threads/pspaces in ascending order 2016-01-12 01:12:38 +00:00
py-infthread.c
py-infthread.exp Add Python InferiorThread.global_num attribute 2016-01-13 11:00:54 +00:00
py-lazy-string.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-lazy-string.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-linetable.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-linetable.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-linetable.S GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-lookup-type.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-mi-objfile-gdb.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-mi-objfile.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-mi-objfile.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-mi.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-objfile-script-gdb.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-objfile-script.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-objfile-script.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-objfile.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-objfile.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-parameter.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-pp-integral.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-pp-integral.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-pp-integral.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-pp-maint.c Fix sorting of enum values in FlagEnumerationPrinter 2016-01-20 13:44:33 -05:00
py-pp-maint.exp Fix sorting of enum values in FlagEnumerationPrinter 2016-01-20 13:44:33 -05:00
py-pp-maint.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-pp-re-notag.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-pp-re-notag.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-pp-re-notag.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-pp-registration.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-pp-registration.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-pp-registration.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-prettyprint.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-prettyprint.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-prettyprint.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-progspace.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-progspace.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-prompt.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-prompt.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-section-script.c [testsuite] @progbits -> %progbits 2016-01-18 14:30:23 +00:00
py-section-script.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-section-script.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-shared-sl.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-shared.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-shared.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-strfns.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-strfns.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-symbol.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-symbol.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-symtab.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-sync-interp.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-sync-interp.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-template.cc GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-template.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-type.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-type.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-typeprint.cc GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-typeprint.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-typeprint.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-unwind-maint.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-unwind-maint.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-unwind-maint.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-unwind.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-unwind.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-unwind.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-value-cc.cc GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-value-cc.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-value.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-value.exp testsuite: Fix false FAILs on too long base directory 2016-01-11 22:12:16 +01:00
py-xmethods.cc GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-xmethods.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
py-xmethods.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
python-1.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
python.c GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
python.exp GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
source1 GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00
source2.py GDB copyright headers update after running GDB's copyright.py script. 2016-01-01 08:43:22 +04:00