[Python] Add methods reference_value and const_value to gdb.Value.

gdb/ChangeLog:

	* NEWS (Python Scripting): Mention the new gdb.Value methods.
	* python/py-value.c (valpy_reference_value): New function.
	(valpy_const_value): Likewise.
	(value_object_methods): Add new methods.
	* value.c (make_cv_value): New function.
	* value.h (make_cv_value): Declare.

gdb/doc/ChangeLog:

	* python.texi (Values From Inferior): Add descriptions of new
	methods gdb.Value.reference_value and gdb.Value.const_value.

gdb/testsuite/ChangeLog:

	* gdb.python/py-xmethods.cc: Enhance test case.
	* gdb.python/py-xmethods.exp: New tests.
	* gdb.python/py-xmethods.py (A_indexoper): New xmethod worker
	function.
	(B_indexoper): Likewise.
	(global_dm_list) : Add new xmethod worker functions.
This commit is contained in:
Siva Chandra 2015-04-25 07:04:40 -07:00
parent 10a52f094e
commit 4c082a81df
11 changed files with 135 additions and 1 deletions

View file

@ -43,6 +43,12 @@ def A_getarrayind(obj, index):
print('From Python <A_getarrayind>:')
return obj['array'][index]
def A_indexoper(obj, index):
return obj['array'][index].reference_value()
def B_indexoper(obj, index):
return obj['array'][index].const_value().reference_value()
type_A = gdb.parse_and_eval('(dop::A *) 0').type.target()
type_B = gdb.parse_and_eval('(dop::B *) 0').type.target()
@ -213,6 +219,16 @@ global_dm_list = [
'^getarrayind$',
A_getarrayind,
type_int),
SimpleXMethodMatcher('A_indexoper',
'^dop::A$',
'operator\\[\\]',
A_indexoper,
type_int),
SimpleXMethodMatcher('B_indexoper',
'^dop::B$',
'operator\\[\\]',
B_indexoper,
type_int)
]
for matcher in global_dm_list: