Skip to content

Commit ed2c92f

Browse files
Make superpmi collection with command more convenient (#48092)
* Make superpmi collection with command more convenient Allow a command to be searched for on the PATH. * Allow searching core_root for tool Fix help string
1 parent 30d84af commit ed2c92f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/coreclr/scripts/superpmi.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239

240240
# Add required arguments
241241
collect_parser.add_argument("collection_command", nargs='?', help=superpmi_collect_help)
242-
collect_parser.add_argument("collection_args", nargs='?', help="Arguments to pass to the SuperPMI collect command.")
242+
collect_parser.add_argument("collection_args", nargs='?', help="Arguments to pass to the SuperPMI collect command. This is a single string; quote it if necessary if the arguments contain spaces.")
243243

244244
collect_parser.add_argument("--pmi", action="store_true", help="Run PMI on a set of directories or assemblies.")
245245
collect_parser.add_argument("--crossgen", action="store_true", help="Run crossgen on a set of directories or assemblies.")
@@ -2972,8 +2972,8 @@ def verify_replay_common_args():
29722972

29732973
coreclr_args.verify(args,
29742974
"collection_command",
2975-
lambda command: command is None or os.path.isfile(command),
2976-
"Unable to find script.")
2975+
lambda unused: True,
2976+
"Unable to set collection_command.")
29772977

29782978
coreclr_args.verify(args,
29792979
"collection_args",
@@ -3108,6 +3108,18 @@ def verify_replay_common_args():
31083108
coreclr_args.temp_dir = os.path.abspath(coreclr_args.temp_dir)
31093109
logging.debug("Using temp_dir %s", coreclr_args.temp_dir)
31103110

3111+
if coreclr_args.collection_command is not None:
3112+
if os.path.isfile(coreclr_args.collection_command):
3113+
coreclr_args.collection_command = os.path.abspath(coreclr_args.collection_command)
3114+
else:
3115+
# Look on path and in Core_Root. Searching Core_Root is useful so you can just specify "corerun.exe" as the collection command in it can be found.
3116+
collection_tool_path = find_tool(coreclr_args, coreclr_args.collection_command, search_core_root=True, search_product_location=False, search_path=True, throw_on_not_found=False)
3117+
if collection_tool_path is None:
3118+
print("Couldn't find collection command \"{}\"".format(coreclr_args.collection_command))
3119+
sys.exit(1)
3120+
coreclr_args.collection_command = collection_tool_path
3121+
logging.info("Using collection command from PATH: \"%s\"", coreclr_args.collection_command)
3122+
31113123
elif coreclr_args.mode == "replay":
31123124

31133125
verify_target_args()

0 commit comments

Comments
 (0)