public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-tromey-python: More changes from review.
@ 2008-11-24 22:20 bauermann
0 siblings, 0 replies; only message in thread
From: bauermann @ 2008-11-24 22:20 UTC (permalink / raw)
To: archer-commits
The branch, archer-tromey-python has been updated
via 4663986956ad35c466e354f6d1997c15cc145e3c (commit)
from 4e1e0f4ed65bdd2262e375ad7fb411905f5c9800 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 4663986956ad35c466e354f6d1997c15cc145e3c
Author: Thiago Jung Bauermann <bauerman@br.ibm.com>
Date: Mon Nov 24 20:20:22 2008 -0200
More changes from review.
* c-lang.c (c_printstr): Renamed to c_print_string. Updated all
references. Added charset argument. Changed fetchlimit to unsigned
int, and use UINT_MAX instead of -1.
* language.c (default_getstr): Renamed to default_get_string. Updated
all references. Added charset argument.
* language.h (language_defn): Renamed la_getstr element to
la_get_string.
* python/python-value.c (valpy_string): Use language-provided charset
if the user doesn't specify one.
* valprint.c (read_string): Clarify description of LEN and FETCHLIMIT
arguments. Allocate buffer even when LEN is zero.
-----------------------------------------------------------------------
Summary of changes:
gdb/ChangeLog | 15 +++++++++++++++
gdb/ada-lang.c | 2 +-
gdb/c-lang.c | 27 ++++++++++++++++-----------
gdb/f-lang.c | 2 +-
gdb/jv-lang.c | 2 +-
gdb/language.c | 9 +++++----
gdb/language.h | 13 ++++++++-----
gdb/m2-lang.c | 2 +-
gdb/objc-lang.c | 2 +-
gdb/p-lang.c | 2 +-
gdb/python/python-value.c | 10 +++++-----
gdb/scm-lang.c | 2 +-
gdb/valprint.c | 13 +++++++------
13 files changed, 63 insertions(+), 38 deletions(-)
First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 447f4da..e90d44d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,18 @@
+2008-11-24 Thiago Jung Bauermann <bauerman@br.ibm.com>
+
+ More changes from review.
+ * c-lang.c (c_printstr): Renamed to c_print_string. Updated all
+ references. Added charset argument. Changed fetchlimit to unsigned
+ int, and use UINT_MAX instead of -1.
+ * language.c (default_getstr): Renamed to default_get_string. Updated
+ all references. Added charset argument.
+ * language.h (language_defn): Renamed la_getstr element to
+ la_get_string.
+ * python/python-value.c (valpy_string): Use language-provided charset
+ if the user doesn't specify one.
+ * valprint.c (read_string): Clarify description of LEN and FETCHLIMIT
+ arguments. Allocate buffer even when LEN is zero.
+
2008-11-24 Tom Tromey <tromey@redhat.com>
* python/lib/gdb/libstdcxx/v6/__init__.py: New file.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 88cb47b..9989c03 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -11064,7 +11064,7 @@ const struct language_defn ada_language_defn = {
ada_language_arch_info,
ada_print_array_index,
default_pass_by_reference,
- default_getstr,
+ default_get_string,
LANG_MAGIC
};
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index c16894c..d3c5189 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -198,12 +198,16 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
failure. In this case, some characters might have been read before the
failure happened. Check LENGTH to recognize this situation.
+ CHARSET is always set to the target charset.
+
Return 0 on success, errno on failure. */
static int
-c_getstr (struct value *value, gdb_byte **buffer, int *length)
+c_get_string (struct value *value, gdb_byte **buffer, int *length,
+ const char **charset)
{
- int fetchlimit, err, width;
+ int err, width;
+ unsigned int fetchlimit;
struct type *type = value_type (value);
struct type *element_type = TYPE_TARGET_TYPE (type);
@@ -224,10 +228,10 @@ c_getstr (struct value *value, gdb_byte **buffer, int *length)
fetchlimit = high_bound - low_bound + 1;
}
else
- fetchlimit = -1;
+ fetchlimit = UINT_MAX;
}
else if (TYPE_CODE (value_type (value)) == TYPE_CODE_PTR)
- fetchlimit = -1;
+ fetchlimit = UINT_MAX;
else
/* We work only with arrays and pointers. */
goto error;
@@ -245,7 +249,7 @@ c_getstr (struct value *value, gdb_byte **buffer, int *length)
just need to copy it to BUFFER. Also, since such strings are arrays
with known size, FETCHLIMIT will hold the size of the array. */
if (((VALUE_LVAL (value) == not_lval)
- || (VALUE_LVAL (value) == lval_internalvar)) && (fetchlimit != -1))
+ || (VALUE_LVAL (value) == lval_internalvar)) && (fetchlimit != UINT_MAX))
{
int i;
const gdb_byte *contents = value_contents (value);
@@ -269,17 +273,18 @@ c_getstr (struct value *value, gdb_byte **buffer, int *length)
if (extract_unsigned_integer (*buffer + *length - width, width) == 0)
*length -= width;
+ *charset = target_charset ();
+
return err;
error:
{
char *type_str;
- struct cleanup *old_chain;
type_str = type_to_string (type);
if (type_str)
{
- old_chain = make_cleanup (xfree, type_str);
+ make_cleanup (xfree, type_str);
error (_("Trying to read string with inappropriate type `%s'."),
type_str);
}
@@ -526,7 +531,7 @@ const struct language_defn c_language_defn =
c_language_arch_info,
default_print_array_index,
default_pass_by_reference,
- c_getstr,
+ c_get_string,
LANG_MAGIC
};
@@ -645,7 +650,7 @@ const struct language_defn cplus_language_defn =
cplus_language_arch_info,
default_print_array_index,
cp_pass_by_reference,
- c_getstr,
+ c_get_string,
LANG_MAGIC
};
@@ -683,7 +688,7 @@ const struct language_defn asm_language_defn =
c_language_arch_info, /* FIXME: la_language_arch_info. */
default_print_array_index,
default_pass_by_reference,
- c_getstr,
+ c_get_string,
LANG_MAGIC
};
@@ -726,7 +731,7 @@ const struct language_defn minimal_language_defn =
c_language_arch_info,
default_print_array_index,
default_pass_by_reference,
- default_getstr,
+ default_get_string,
LANG_MAGIC
};
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index d25ef80..76543a8 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -343,7 +343,7 @@ const struct language_defn f_language_defn =
f_language_arch_info,
default_print_array_index,
default_pass_by_reference,
- default_getstr,
+ default_get_string,
LANG_MAGIC
};
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index 2c8bee5..11cd321 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -1131,7 +1131,7 @@ const struct language_defn java_language_defn =
java_language_arch_info,
default_print_array_index,
default_pass_by_reference,
- default_getstr,
+ default_get_string,
LANG_MAGIC
};
diff --git a/gdb/language.c b/gdb/language.c
index b2e1867..8afab87 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -1044,7 +1044,8 @@ default_print_array_index (struct value *index_value, struct ui_file *stream,
}
int
-default_getstr (struct value *value, gdb_byte **buffer, int *length)
+default_get_string (struct value *value, gdb_byte **buffer, int *length,
+ const char **charset)
{
error (_("Getting a string is unsupported in this language."));
}
@@ -1171,7 +1172,7 @@ const struct language_defn unknown_language_defn =
unknown_language_arch_info, /* la_language_arch_info. */
default_print_array_index,
default_pass_by_reference,
- default_getstr,
+ default_get_string,
LANG_MAGIC
};
@@ -1210,7 +1211,7 @@ const struct language_defn auto_language_defn =
unknown_language_arch_info, /* la_language_arch_info. */
default_print_array_index,
default_pass_by_reference,
- default_getstr,
+ default_get_string,
LANG_MAGIC
};
@@ -1248,7 +1249,7 @@ const struct language_defn local_language_defn =
unknown_language_arch_info, /* la_language_arch_info. */
default_print_array_index,
default_pass_by_reference,
- default_getstr,
+ default_get_string,
LANG_MAGIC
};
\f
diff --git a/gdb/language.h b/gdb/language.h
index 1033ecd..9c42dd4 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -285,8 +285,10 @@ struct language_defn
/* Obtain a string from the inferior, storing it in a newly allocated
buffer in BUFFER, which should be freed by the caller. LENGTH will
hold the size in bytes of the string (only actual characters, excluding
- an eventual terminating null character). */
- int (*la_getstr) (struct value *value, gdb_byte **buffer, int *length);
+ an eventual terminating null character). CHARSET will hold the encoding
+ used in the string. */
+ int (*la_get_string) (struct value *value, gdb_byte **buffer, int *length,
+ const char **charset);
/* Add fields above this point, so the magic number is always last. */
/* Magic number for compat checking */
@@ -386,8 +388,8 @@ extern enum language set_language (enum language);
force_ellipses,options))
#define LA_EMIT_CHAR(ch, stream, quoter) \
(current_language->la_emitchar(ch, stream, quoter))
-#define LA_GET_STRING(value, buffer, length) \
- (current_language->la_getstr(value, buffer, length))
+#define LA_GET_STRING(value, buffer, length, encoding) \
+ (current_language->la_get_string(value, buffer, length, encoding))
#define LA_PRINT_ARRAY_INDEX(index_value, stream, optins) \
(current_language->la_print_array_index(index_value, stream, options))
@@ -497,6 +499,7 @@ int default_pass_by_reference (struct type *type);
void default_print_typedef (struct type *type, struct symbol *new_symbol,
struct ui_file *stream);
-int default_getstr (struct value *value, gdb_byte **buffer, int *length);
+int default_get_string (struct value *value, gdb_byte **buffer, int *length,
+ const char **charset);
#endif /* defined (LANGUAGE_H) */
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 9742fd3..fe6c74e 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -394,7 +394,7 @@ const struct language_defn m2_language_defn =
m2_language_arch_info,
default_print_array_index,
default_pass_by_reference,
- default_getstr,
+ default_get_string,
LANG_MAGIC
};
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index dcb527a..4a84398 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -531,7 +531,7 @@ const struct language_defn objc_language_defn = {
c_language_arch_info,
default_print_array_index,
default_pass_by_reference,
- default_getstr,
+ default_get_string,
LANG_MAGIC
};
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index b08a7bf..c344fea 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -433,7 +433,7 @@ const struct language_defn pascal_language_defn =
pascal_language_arch_info,
default_print_array_index,
default_pass_by_reference,
- default_getstr,
+ default_get_string,
LANG_MAGIC
};
diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index 5be60b8..807f914 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -165,16 +165,15 @@ valpy_string (PyObject *self, PyObject *args)
volatile struct gdb_exception except;
PyObject *unicode;
const char *encoding = NULL;
+ const char *user_encoding = NULL;
+ const char *la_encoding = NULL;
- if (!PyArg_ParseTuple (args, "|s", &encoding))
+ if (!PyArg_ParseTuple (args, "|s", &user_encoding))
return NULL;
- if (!encoding)
- encoding = target_charset ();
-
TRY_CATCH (except, RETURN_MASK_ALL)
{
- ret = LA_GET_STRING (value, &buffer, &length);
+ ret = LA_GET_STRING (value, &buffer, &length, &la_encoding);
}
GDB_PY_HANDLE_EXCEPTION (except);
@@ -188,6 +187,7 @@ valpy_string (PyObject *self, PyObject *args)
return NULL;
}
+ encoding = user_encoding? user_encoding : la_encoding;
unicode = PyUnicode_Decode (buffer, length, encoding, NULL);
xfree (buffer);
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index 1d6ec0e..786758f 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -273,7 +273,7 @@ const struct language_defn scm_language_defn =
c_language_arch_info,
default_print_array_index,
default_pass_by_reference,
- default_getstr,
+ default_get_string,
LANG_MAGIC
};
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 9b6ac8a..b3e5529 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1214,11 +1214,11 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int *errnoptr
free, and BYTES_READ will be set to the number of bytes read. Returns 0 on
success, or errno on failure.
- If LEN is -1, stops at the first null character (not necessarily the first
- null byte) up to a maximum of FETCHLIMIT characters, otherwise reading
- proceeds (including null characters) until LEN characters have been read.
- Set FETCHLIMIT to UINT_MAX to read as many characters as possible from the
- string.
+ If LEN > 0, reads exactly LEN characters (including eventual NULs in
+ the middle or end of the string). If LEN is -1, stops at the first
+ null character (not necessarily the first null byte) up to a maximum
+ of FETCHLIMIT characters. Set FETCHLIMIT to UINT_MAX to read as many
+ characters as possible from the string.
Unless an exception is thrown, BUFFER will always be allocated, even on
failure. In this case, some characters might have been read before the
@@ -1328,7 +1328,8 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
}
else
{ /* Length of string is really 0! */
- *buffer = bufptr = NULL;
+ /* We always allocate *buffer. */
+ *buffer = bufptr = xmalloc (1);
errcode = 0;
}
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-11-24 22:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-24 22:20 [SCM] archer-tromey-python: More changes from review bauermann
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).