[Pdbg] [PATCH v2 09/15] main: Fix probe() to print targets correctly

Amitay Isaacs amitay at ozlabs.org
Wed Nov 14 16:30:06 AEDT 2018


On Tue, 2018-11-13 at 15:26 +1100, Alistair Popple wrote:
> HI Amitay,
> 
> I think this looks good. I know we've talked about this previously
> but I'd 
> like to confirm my understanding. The previous behaviour was that
> when 
> selecting a target all of a targets parents would get marked as
> selected, 
> where as this series changes things such that target_selected() only
> returns 
> true for child/leaf nodes (rather than parents as well). Is that
> correct?

The target selection using -p/-c/-t/-a selected all the matching
pibs/cores/threads.  With path based targeting changes, the same
behaviour is maintained, so the same targets will be selected.  The
target selection is clear from the output of probe command.

For targets selected with -P, it only selects the matching targets.

target_selected() will return true only if the specified target is
selected irrespective of the states of parent(s) and child(ren).


> On Friday, 9 November 2018 6:10:05 PM AEDT Amitay Isaacs wrote:
> > Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
> > ---
> >  src/main.c              | 11 -----------
> >  tests/test_selection.sh | 43 +++--------------------------------
> > ------
> >  2 files changed, 3 insertions(+), 51 deletions(-)
> > 
> > diff --git a/src/main.c b/src/main.c
> > index 1a7d610..2a11687 100644
> > --- a/src/main.c
> > +++ b/src/main.c
> > @@ -676,8 +676,6 @@ void print_target(struct pdbg_target *target,
> > int level)
> > struct pdbg_target *next;
> >  	enum pdbg_target_status status;
> > 
> > -	pdbg_target_probe(target);
> > -
> >  	/* Does this target actually exist? */
> >  	status = pdbg_target_status(target);
> >  	if (status != PDBG_TARGET_ENABLED)
> > @@ -706,9 +704,6 @@ void print_target(struct pdbg_target *target,
> > int level)
> > }
> > 
> >  	pdbg_for_each_child_target(target, next) {
> > -		if (!target_selected(next))
> > -			continue;
> > -
> >  		print_target(next, level + 1);
> >  	}
> >  }
> > @@ -718,15 +713,9 @@ static int probe(void)
> >  	struct pdbg_target *target;
> > 
> >  	pdbg_for_each_class_target("pib", target) {
> > -		if (!target_selected(target))
> > -			continue;
> > -
> >  		print_target(target, 0);
> >  	}
> > 
> > -	printf("\nNote that only selected targets will be shown above.
> > If none 
> are
> > shown\n" -			"try adding '-a' to select all
> > targets\n");
> > -
> >  	return 1;
> >  }
> >  OPTCMD_DEFINE_CMD(probe, probe);
> > diff --git a/tests/test_selection.sh b/tests/test_selection.sh
> > index 2b23ec1..8909796 100755
> > --- a/tests/test_selection.sh
> > +++ b/tests/test_selection.sh
> > @@ -13,10 +13,9 @@ do_skip ()
> >  	fi
> >  }
> > 
> > -test_result 0 <<EOF
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> > +test_result 1 <<EOF
> > +No valid targets found or specified. Try adding -p/-c/-t options
> > to specify
> > a target. +Alternatively run 'pdbg -a probe' to get a list of all
> > valid
> > targets EOF
> > 
> >  do_skip
> > @@ -128,9 +127,6 @@ p7: Fake PIB
> >      c3: Fake Core
> >          t0: Fake Thread
> >          t1: Fake Thread
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> >  EOF
> > 
> >  do_skip
> > @@ -151,9 +147,6 @@ p0: Fake PIB
> >      c3: Fake Core
> >          t0: Fake Thread
> >          t1: Fake Thread
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> >  EOF
> > 
> >  do_skip
> > @@ -193,9 +186,6 @@ p7: Fake PIB
> >      c0: Fake Core
> >          t0: Fake Thread
> >          t1: Fake Thread
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> >  EOF
> > 
> >  do_skip
> > @@ -275,9 +265,6 @@ p7: Fake PIB
> >          t0: Fake Thread
> >      c3: Fake Core
> >          t0: Fake Thread
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> >  EOF
> > 
> >  do_skip
> > @@ -289,9 +276,6 @@ p0: Fake PIB
> >      c2: Fake Core
> >          t0: Fake Thread
> >          t1: Fake Thread
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> >  EOF
> > 
> >  do_skip
> > @@ -302,9 +286,6 @@ test_result 0 <<EOF
> >  p0: Fake PIB
> >      c2: Fake Core
> >          t1: Fake Thread
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> >  EOF
> > 
> >  do_skip
> > @@ -328,9 +309,6 @@ p6: Fake PIB
> >      c0: Fake Core
> >          t0: Fake Thread
> > 
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> > -
> >  EOF
> > 
> >  do_skip
> > @@ -339,9 +317,6 @@ test_run pdbg -b fake -p1-3,5,5-6 -c0 -t0 probe
> > 
> >  test_result 0 <<EOF
> >  p0: Fake PIB
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> >  EOF
> > 
> >  do_skip
> > @@ -391,9 +366,6 @@ test_run pdbg -b fake -t0 -p0 probe
> >  test_result 0 <<EOF
> >  p0: Fake PIB
> >      c0: Fake Core
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> >  EOF
> > 
> >  do_skip
> > @@ -404,9 +376,6 @@ test_result 0 <<EOF
> >  p0: Fake PIB
> >      c0: Fake Core
> >          t0: Fake Thread
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> >  EOF
> > 
> >  do_skip
> > @@ -434,9 +403,6 @@ p7: Fake PIB
> >          t0: Fake Thread
> >      c3: Fake Core
> >          t0: Fake Thread
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> >  EOF
> > 
> >  do_skip
> > @@ -464,9 +430,6 @@ p7: Fake PIB
> >          t1: Fake Thread
> >      c3: Fake Core
> >          t1: Fake Thread
> > -
> > -Note that only selected targets will be shown above. If none are
> > shown
> > -try adding '-a' to select all targets
> >  EOF
> > 
> >  do_skip
> 
> 

Amitay.
-- 

You never get a second chance to make a good first impression.



More information about the Pdbg mailing list