Fix issues with multiple inferiors
authorLaurent Morichetti <laurent.morichetti@amd.com>
Wed, 15 Jan 2020 02:14:13 +0000 (18:14 -0800)
committerLaurent Morichetti <laurent.morichetti@amd.com>
Wed, 15 Jan 2020 06:24:57 +0000 (22:24 -0800)
Issue #1:
Thread 3 "bit_extract_kernel" hit Breakpoint 1, bit_extract_kernel ()
(gdb) add-inferior
[New inferior 2]
Added inferior 2 on connection 1 (native)
(gdb) info threads
amd_dbgapi_wave_list failed (rc=-14)

An inferior may not have yet been attached when update_thread_list is
called. The inferior should be skipped if its process_id is null.

Issue #2:
Thread 3 "bit_extract_kernel" hit Breakpoint 1, bit_extract_kernel ()
(gdb) add-inferior -exec /bin/ls
[New inferior 2]
Added inferior 2 on connection 1 (native)
Reading symbols from /bin/ls...
(No debugging symbols found in /bin/ls)
(gdb) inferior 2
[Switching to inferior 2 [<null>] (/bin/ls)]
(gdb) run
Starting program: /bin/ls
Warning:
Cannot insert breakpoint -8.
Cannot access memory at address 0x7fffedaa265b

Internal ROCgdbapi breakpoints should not be re-evaluated for new
inferiors. They are inserted for a specific process_id, and removed
when the process is detached.

gdb/ChangeLog:
        * gdb/rocm-tdep.c: Skip inferiors without process_ids. Override
        breakpoint_ops::re_set for rocm internal breakpoints to
        disable re-evaluation.

Change-Id: Icb0be93b74aae1cf80c7f1657cf6d01e16eb8efb

gdb/rocm-tdep.c

index 87f93e65081147194ee01afff7d9f4e37d37ee05..55b4c79d4500cc59162460431e89a4278a27116d 100644 (file)
@@ -262,6 +262,11 @@ get_amd_dbgapi_process_id (struct inferior *inferior)
   return get_rocm_inferior_info (inferior)->process_id;
 }
 
+static void
+rocm_breakpoint_re_set (struct breakpoint *b)
+{
+}
+
 static void
 rocm_breakpoint_check_status (struct bpstats *bs)
 {
@@ -1033,16 +1038,23 @@ rocm_target_ops::update_thread_list ()
 {
   for (inferior *inf : all_inferiors ())
     {
-      amd_dbgapi_process_id_t process_id = get_amd_dbgapi_process_id (inf);
+      amd_dbgapi_process_id_t process_id;
       amd_dbgapi_wave_id_t *wave_list;
       size_t count;
 
+      process_id = get_amd_dbgapi_process_id (inf);
+      if (process_id.handle == AMD_DBGAPI_PROCESS_NONE.handle)
+        {
+          /* The inferior may not be attached yet.  */
+          continue;
+        }
+
       amd_dbgapi_changed_t changed;
       amd_dbgapi_status_t status;
       if ((status
            = amd_dbgapi_wave_list (process_id, &count, &wave_list, &changed))
           != AMD_DBGAPI_STATUS_SUCCESS)
-        error (_ ("amd_dbgapi_wave_list failed (rc=%d"), status);
+        error (_ ("amd_dbgapi_wave_list failed (rc=%d)"), status);
 
       if (changed == AMD_DBGAPI_CHANGED_NO)
         continue;
@@ -1062,13 +1074,14 @@ rocm_target_ops::update_thread_list ()
       for (auto &&tid : threads)
         {
           ptid_t wave_ptid (inf->pid, 1, tid);
+          /* FIXME: is this really needed?
           amd_dbgapi_wave_state_t state;
 
           if (amd_dbgapi_wave_get_info (
                   process_id, get_amd_dbgapi_wave_id (wave_ptid),
                   AMD_DBGAPI_WAVE_INFO_STATE, sizeof (state), &state)
               != AMD_DBGAPI_STATUS_SUCCESS)
-            continue;
+            continue;*/
 
           add_thread_silent (inf->process_target (), wave_ptid);
           set_running (inf->process_target (), wave_ptid, 1);
@@ -1348,6 +1361,7 @@ static amd_dbgapi_callbacks_t dbgapi_callbacks = {
           {
             rocm_breakpoint_ops = bkpt_breakpoint_ops;
             rocm_breakpoint_ops.check_status = rocm_breakpoint_check_status;
+            rocm_breakpoint_ops.re_set = rocm_breakpoint_re_set;
           }
 
         auto it = info->breakpoint_map.find (breakpoint_id.handle);
This page took 0.02728 seconds and 4 git commands to generate.