[PATCHv4,5/5] gdb: Don't store a thread-id for floating varobj
Commit Message
When creating a varobj with -var-create a user can create either fixed
varobj, or floating varobj.
A fixed varobj will always be evaluated within the thread/frame/block in
which the varobj was created, if that thread/frame/block is no longer
available then the varobj is considered out of scope.
A floating varobj will always be evaluated within the current
thread/frame/block.
Despite never using them GDB was storing the thread/frame/block into a
floating varobj, and the thread-id would then be displayed when GDB
reported on the state of the varobj, this could confuse a user into
thinking that the thread-id was relevant.
This commit prevents GDB storing the thread/frame/block onto floating
varobj, and updates the few tests where this impacts the results.
gdb/ChangeLog:
* varobj.c (varobj_create): Don't set valid_block when creating a
floating varobj.
gdb/testsuite/ChangeLog:
* gdb.python/py-mi.exp: Don't expect a thread-id for floating
varobj.
* gdb.mi/mi-var-create-rtti.exp: Likewise.
---
gdb/ChangeLog | 5 +++++
gdb/testsuite/ChangeLog | 6 ++++++
gdb/testsuite/gdb.mi/mi-var-create-rtti.exp | 2 +-
gdb/testsuite/gdb.python/py-mi.exp | 12 ++++++------
gdb/varobj.c | 3 ++-
5 files changed, 20 insertions(+), 8 deletions(-)
Comments
On 2017-10-19 09:27 AM, Andrew Burgess wrote:
> When creating a varobj with -var-create a user can create either fixed
> varobj, or floating varobj.
>
> A fixed varobj will always be evaluated within the thread/frame/block in
> which the varobj was created, if that thread/frame/block is no longer
> available then the varobj is considered out of scope.
>
> A floating varobj will always be evaluated within the current
> thread/frame/block.
>
> Despite never using them GDB was storing the thread/frame/block into a
> floating varobj, and the thread-id would then be displayed when GDB
> reported on the state of the varobj, this could confuse a user into
> thinking that the thread-id was relevant.
>
> This commit prevents GDB storing the thread/frame/block onto floating
> varobj, and updates the few tests where this impacts the results.
>
> gdb/ChangeLog:
>
> * varobj.c (varobj_create): Don't set valid_block when creating a
> floating varobj.
>
> gdb/testsuite/ChangeLog:
>
> * gdb.python/py-mi.exp: Don't expect a thread-id for floating
> varobj.
> * gdb.mi/mi-var-create-rtti.exp: Likewise.
> ---
> gdb/ChangeLog | 5 +++++
> gdb/testsuite/ChangeLog | 6 ++++++
> gdb/testsuite/gdb.mi/mi-var-create-rtti.exp | 2 +-
> gdb/testsuite/gdb.python/py-mi.exp | 12 ++++++------
> gdb/varobj.c | 3 ++-
> 5 files changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp b/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
> index afc9c248ae..85ead72e7b 100644
> --- a/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
> +++ b/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
> @@ -52,6 +52,6 @@ mi_gdb_test "-var-create sp1 * ((void*)\$sp)" \
> "\\^done,name=\"sp1\",numchild=\"0\",value=\"$hex\",type=\"void \\*\",thread-id=\"$decimal\",has_more=\"0\"" \
> "-var-create sp1 * \$sp"
> mi_gdb_test "-var-create sp2 @ ((void*)\$sp)" \
> - "\\^done,name=\"sp2\",numchild=\"0\",value=\"$hex\",type=\"void \\*\",thread-id=\"$decimal\",has_more=\"0\"" \
> + "\\^done,name=\"sp2\",numchild=\"0\",value=\"$hex\",type=\"void \\*\",has_more=\"0\"" \
> "-var-create sp2 @ \$sp"
> gdb_exit
> diff --git a/gdb/testsuite/gdb.python/py-mi.exp b/gdb/testsuite/gdb.python/py-mi.exp
> index 736dc7a0d6..aa9a2f12a2 100644
> --- a/gdb/testsuite/gdb.python/py-mi.exp
> +++ b/gdb/testsuite/gdb.python/py-mi.exp
> @@ -101,7 +101,7 @@ mi_varobj_update_dynamic container "varobj update 1" {
> type_changed false new_num_children 1 dynamic 1 has_more 0
> } {
> } {
> - { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
> + { name {container.\[0\]} exp {\[0\]} numchild 0 type int }
> }
>
> mi_next "next over update 2"
> @@ -110,7 +110,7 @@ mi_varobj_update_dynamic container "varobj update 2" {
> type_changed false new_num_children 2 dynamic 1 has_more 0
> } {
> } {
> - { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
> + { name {container.\[1\]} exp {\[1\]} numchild 0 type int }
> }
>
> mi_gdb_test "-var-set-visualizer container None" \
> @@ -129,8 +129,8 @@ mi_varobj_update_dynamic container "varobj update after choosing default" {
> type_changed false new_num_children 2 dynamic 1 has_more 0
> } {
> } {
> - { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
> - { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
> + { name {container.\[0\]} exp {\[0\]} numchild 0 type int }
> + { name {container.\[1\]} exp {\[1\]} numchild 0 type int }
> }
>
> mi_gdb_test "-var-set-visualizer container ContainerPrinter" \
> @@ -142,8 +142,8 @@ mi_varobj_update_dynamic container \
> type_changed false new_num_children 2 dynamic 1 has_more 0
> } {
> } {
> - { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
> - { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
> + { name {container.\[0\]} exp {\[0\]} numchild 0 type int }
> + { name {container.\[1\]} exp {\[1\]} numchild 0 type int }
> }
>
> mi_list_varobj_children_range container 1 2 2 {
> diff --git a/gdb/varobj.c b/gdb/varobj.c
> index d8b927ef4f..ee555b39ac 100644
> --- a/gdb/varobj.c
> +++ b/gdb/varobj.c
> @@ -351,7 +351,8 @@ varobj_create (const char *objname,
> }
>
> var->format = variable_default_display (var);
> - var->root->valid_block = innermost_block.block ();
> + var->root->valid_block =
> + var->root->floating ? NULL : innermost_block.block ();
> var->name = expression;
> /* For a root var, the name and the expr are the same. */
> var->path_expr = expression;
>
This LGTM.
Simon
@@ -52,6 +52,6 @@ mi_gdb_test "-var-create sp1 * ((void*)\$sp)" \
"\\^done,name=\"sp1\",numchild=\"0\",value=\"$hex\",type=\"void \\*\",thread-id=\"$decimal\",has_more=\"0\"" \
"-var-create sp1 * \$sp"
mi_gdb_test "-var-create sp2 @ ((void*)\$sp)" \
- "\\^done,name=\"sp2\",numchild=\"0\",value=\"$hex\",type=\"void \\*\",thread-id=\"$decimal\",has_more=\"0\"" \
+ "\\^done,name=\"sp2\",numchild=\"0\",value=\"$hex\",type=\"void \\*\",has_more=\"0\"" \
"-var-create sp2 @ \$sp"
gdb_exit
@@ -101,7 +101,7 @@ mi_varobj_update_dynamic container "varobj update 1" {
type_changed false new_num_children 1 dynamic 1 has_more 0
} {
} {
- { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
+ { name {container.\[0\]} exp {\[0\]} numchild 0 type int }
}
mi_next "next over update 2"
@@ -110,7 +110,7 @@ mi_varobj_update_dynamic container "varobj update 2" {
type_changed false new_num_children 2 dynamic 1 has_more 0
} {
} {
- { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
+ { name {container.\[1\]} exp {\[1\]} numchild 0 type int }
}
mi_gdb_test "-var-set-visualizer container None" \
@@ -129,8 +129,8 @@ mi_varobj_update_dynamic container "varobj update after choosing default" {
type_changed false new_num_children 2 dynamic 1 has_more 0
} {
} {
- { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
- { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
+ { name {container.\[0\]} exp {\[0\]} numchild 0 type int }
+ { name {container.\[1\]} exp {\[1\]} numchild 0 type int }
}
mi_gdb_test "-var-set-visualizer container ContainerPrinter" \
@@ -142,8 +142,8 @@ mi_varobj_update_dynamic container \
type_changed false new_num_children 2 dynamic 1 has_more 0
} {
} {
- { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
- { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
+ { name {container.\[0\]} exp {\[0\]} numchild 0 type int }
+ { name {container.\[1\]} exp {\[1\]} numchild 0 type int }
}
mi_list_varobj_children_range container 1 2 2 {
@@ -351,7 +351,8 @@ varobj_create (const char *objname,
}
var->format = variable_default_display (var);
- var->root->valid_block = innermost_block.block ();
+ var->root->valid_block =
+ var->root->floating ? NULL : innermost_block.block ();
var->name = expression;
/* For a root var, the name and the expr are the same. */
var->path_expr = expression;