** The 'qualified' argument to gdb.Breakpoint constructor will no
longer accept non-bool types.
+ ** Added gdb.Block.subblocks. Returns a list of blocks contained in that
+ block.
+
* Debugger Adapter Protocol changes
** The "scopes" request will now return a scope holding global
this attribute holds @code{None}. This attribute is not writable.
@end defvar
+@defvar Block.subblocks
+A list of blocks nested in this block. If there are no blocks nested,
+this attribute holds an empty list. This attribute is not writable.
+@end defvar
+
@defvar Block.global_block
The global block associated with this block. This attribute is not
writable.
Py_RETURN_NONE;
}
+static PyObject *
+blpy_get_subblocks (PyObject *self, void *closure)
+{
+ const struct block *block;
+
+ BLPY_REQUIRE_VALID (self, block);
+
+ gdbpy_ref<> list (PyList_New (0));
+ if (list == nullptr)
+ return nullptr;
+
+ compunit_symtab *cu = block->global_block ()->compunit ();
+
+ for (const struct block *each : cu->blockvector ()->blocks ())
+ {
+ if (each->superblock () == block)
+ {
+ gdbpy_ref<> item (block_to_block_object (each, cu->objfile ()));
+
+ if (item.get () == nullptr
+ || PyList_Append (list.get (), item.get ()) == -1)
+ return nullptr;
+ }
+ }
+
+ return list.release ();
+}
+
/* Return the global block associated to this block. */
static PyObject *
"Whether this block is a static block.", NULL },
{ "is_global", blpy_is_global, NULL,
"Whether this block is a global block.", NULL },
+ { "subblocks", blpy_get_subblocks, nullptr,
+ "List of blocks contained in this block.", nullptr },
{ NULL } /* Sentinel */
};
"Get block, static_block" 1
gdb_test "python print (gblock.is_global)" "True" "is the global block"
gdb_test "python print (sblock.is_static)" "True" "is the static block"
+gdb_test "python print (len(gblock.subblocks) > 0)" "True" \
+ "global block contains at least one block"
+gdb_test "python print (sblock in gblock.subblocks)" "True" \
+ "global block contains at static block"
# Move up superblock(s) until we reach function block_func.
gdb_test_no_output "python block = block.superblock" "get superblock"