From ac0dda894231e6281e7739aa0ea01a4e9697c747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lira=20Junior?= Date: Mon, 9 Oct 2023 20:43:59 -0300 Subject: [lldb] add stop-at-user-entry option to process launch (#67019) ## Description This pull request adds a new `stop-at-user-entry` option to LLDB `process launch` command, allowing users to launch a process and pause execution at the entry point of the program (for C-based languages, `main` function). ## Motivation This option provides a convenient way to begin debugging a program by launching it and breaking at the desired entry point. ## Changes Made - Added `stop-at-user-entry` option to `Options.td` and the corresponding case in `CommandOptionsProcessLaunch.cpp` (short option is 'm') - Implemented `GetUserEntryPointName` method in the Language plugins available at the moment. - Declared the `CreateBreakpointAtUserEntry` method in the Target API. - Create Shell test for the command `command-process-launch-user-entry.test`. ## Usage `process launch --stop-at-user-entry` or `process launch -m` launches the process and pauses execution at the entry point of the program. --- lldb/source/Commands/CommandOptionsProcessLaunch.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lldb/source/Commands/CommandOptionsProcessLaunch.cpp') diff --git a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp index 85ad8ff5e071..b1c13d4df79e 100644 --- a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp +++ b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp @@ -34,11 +34,15 @@ Status CommandOptionsProcessLaunch::SetOptionValue( Status error; const int short_option = g_process_launch_options[option_idx].short_option; + TargetSP target_sp = + execution_context ? execution_context->GetTargetSP() : TargetSP(); switch (short_option) { case 's': // Stop at program entry point launch_info.GetFlags().Set(eLaunchFlagStopAtEntry); break; - + case 'm': // Stop at user entry point + target_sp->CreateBreakpointAtUserEntry(error); + break; case 'i': // STDIN for read only { FileAction action; @@ -89,8 +93,6 @@ Status CommandOptionsProcessLaunch::SetOptionValue( break; case 'a': { - TargetSP target_sp = - execution_context ? execution_context->GetTargetSP() : TargetSP(); PlatformSP platform_sp = target_sp ? target_sp->GetPlatform() : PlatformSP(); launch_info.GetArchitecture() = -- cgit v1.2.3