This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Add an Objfile.lookup_global_symbol function
- From: Tom Tromey <tom at tromey dot com>
- To: "Christian Biesinger via gdb-patches" <gdb-patches at sourceware dot org>
- Cc: Christian Biesinger <cbiesinger at google dot com>
- Date: Wed, 26 Jun 2019 15:12:13 -0600
- Subject: Re: [PATCH] Add an Objfile.lookup_global_symbol function
- References: <20190625220832.247935-1-cbiesinger@google.com>
>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
Christian> +static PyObject *
Christian> +objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
Christian> +{
...
Christian> + if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &symbol_name,
Christian> + &domain))
Christian> + Py_RETURN_NONE;
Error cases must return NULL.
Christian> + if (!sym) {
gdb style is an explicit check, like sym != nullptr.
Also the brace is misplaced.
Christian> struct block_symbol
Christian> lookup_global_symbol_from_objfile (struct objfile *main_objfile,
Christian> + int block_index,
Christian> const char *name,
Christian> const domain_enum domain)
I suspect the new parameter should probably have type `enum block_enum'.
Christian> + block_index can be GLOBAL_BLOCK, STATIC_BLOCK, etc.
Does the "etc" case really work? If not it should just assert that the
value is one of GLOBAL_BLOCK or STATIC_BLOCK.
Christian> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"global_var\").name)" \
Christian> + "global_var" "lookup_global_symbol find a valid symbol"
Christian> +gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_global_symbol (\"static_var\").name)" \
Christian> + "static_var" "lookup_global_symbol find a valid static symbol"
Perhaps this ought to test a case where it returns None.
Tom