mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-08 00:32:05 +08:00
2009-07-10 Phil Muldoon <pmuldoon@redhat.com>
* python/python-internal.h (apply_varobj_pretty_printer): Update definition. (python_string_to_target_python_string): Add definition. * python/python-utils.c (unicode_to_encoded_python_string) (unicode_to_target_python_string) (python_string_to_target_python_string): New Functions. * python/python-prettyprint.c (pretty_print_one_value): Likewise. (print_string_repr): Refactor to logic to account for PyObject returned strings. (apply_varobj_pretty_printer): Likewise. * python/python-value.c (valpy_string): Parse length keyword. Use length keyword in LA_GET_STRING. * varobj.c (value_get_print_value): Refactor logic to account for PyObject returned strings. * c-lang.c (c_get_string): If the length parameter is specified, use that. Return value in characters. Update comments. * language.h: Update c_get_string prototype comments. 2009-07-10 Phil Muldoon <pmuldoon@redhat.com> * gdb.texinfo (Values From Inferior): Add length parameter description. 2009-07-10 Phil Muldoon <pmuldoon@redhat.com> * gdb.python/python-prettyprint.c: Add counted null string structure. * gdb.python/python-prettyprint.exp: Print null string. Test for embedded nulls. * gdb.python/python-prettyprint.py (pp_ns): New Function. * gdb.python/python-value.exp (test_value_in_inferior): Add variable length string fetch tests. * gdb.python/python-value.c (main): Add strings for string fetch tests.
This commit is contained in:
@ -189,13 +189,16 @@ valpy_get_type (PyObject *self, void *closure)
|
||||
return obj->type;
|
||||
}
|
||||
|
||||
/* Implementation of gdb.Value.string ([encoding] [, errors]) -> string
|
||||
Return Unicode string with value contents. If ENCODING is not given,
|
||||
the string is assumed to be encoded in the target's charset. */
|
||||
/* Implementation of gdb.Value.string ([encoding] [, errors]
|
||||
[, length]) -> string. Return Unicode string with value contents.
|
||||
If ENCODING is not given, the string is assumed to be encoded in
|
||||
the target's charset. If LENGTH is provided, only fetch string to
|
||||
the length provided. */
|
||||
|
||||
static PyObject *
|
||||
valpy_string (PyObject *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
int length, ret = 0;
|
||||
int length = -1, ret = 0;
|
||||
gdb_byte *buffer;
|
||||
struct value *value = ((value_object *) self)->value;
|
||||
volatile struct gdb_exception except;
|
||||
@ -204,10 +207,10 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw)
|
||||
const char *errors = NULL;
|
||||
const char *user_encoding = NULL;
|
||||
const char *la_encoding = NULL;
|
||||
static char *keywords[] = { "encoding", "errors" };
|
||||
static char *keywords[] = { "encoding", "errors", "length" };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kw, "|ss", keywords,
|
||||
&user_encoding, &errors))
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kw, "|ssi", keywords,
|
||||
&user_encoding, &errors, &length))
|
||||
return NULL;
|
||||
|
||||
TRY_CATCH (except, RETURN_MASK_ALL)
|
||||
@ -937,7 +940,7 @@ static PyMethodDef value_object_methods[] = {
|
||||
{ "cast", valpy_cast, METH_VARARGS, "Cast the value to the supplied type." },
|
||||
{ "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." },
|
||||
{ "string", (PyCFunction) valpy_string, METH_VARARGS | METH_KEYWORDS,
|
||||
"string ([encoding] [, errors]) -> string\n\
|
||||
"string ([encoding] [, errors] [, length]) -> string\n\
|
||||
Return Unicode string representation of the value." },
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
Reference in New Issue
Block a user