This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add an Objfile.lookup_global_symbol function


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]