[1/7] Reimplement DAP's stopAtBeginningOfMainSubprogram

Message ID 20241121-dap-launch-v3-v1-1-c1fa046b3285@adacore.com
State New
Headers
Series Rewrite DAP launch and attach implementations |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Tom Tromey Nov. 21, 2024, 8:35 p.m. UTC
  Right now, stopAtBeginningOfMainSubprogram is implemented "by hand",
but then later the launch function uses "starti" to implement
stopOnEntry.  This patch unifies this code and rewrites it to use
"start" when appropriate.
---
 gdb/python/lib/gdb/dap/launch.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
  

Patch

diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/launch.py
index 65444bf976a03ffe6d8ff0d927dd66adf63256d1..6444c8b7b6741c4847a6c12df78685afca37847a 100644
--- a/gdb/python/lib/gdb/dap/launch.py
+++ b/gdb/python/lib/gdb/dap/launch.py
@@ -53,17 +53,19 @@  def launch(
     if program is not None:
         file_command(program)
     inf = gdb.selected_inferior()
-    if stopAtBeginningOfMainSubprogram:
-        main = inf.main_name
-        if main is not None:
-            exec_and_log("tbreak " + main)
     inf.arguments = args
     if env is not None:
         inf.clear_env()
         for name, value in env.items():
             inf.set_env(name, value)
     expect_process("process")
-    exec_and_expect_stop("starti" if stopOnEntry else "run")
+    if stopAtBeginningOfMainSubprogram:
+        cmd = "start"
+    elif stopOnEntry:
+        cmd = "starti"
+    else:
+        cmd = "run"
+    exec_and_expect_stop(cmd)
 
 
 @request("attach")