From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30047 invoked by alias); 17 Aug 2002 00:58:03 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 30036 invoked from network); 17 Aug 2002 00:58:02 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sources.redhat.com with SMTP; 17 Aug 2002 00:58:02 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id D82FBD2CBD; Fri, 16 Aug 2002 17:58:03 -0700 (PDT) Date: Fri, 16 Aug 2002 17:58:00 -0000 From: Joel Brobecker To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] enable software single step on alpha-osf Message-ID: <20020817005803.GH911@gnat.com> References: <20020718203205.GB26990@gnat.com> <3D4DBBC8.5000906@ges.redhat.com> <20020805184920.GC892@gnat.com> <3D5D323A.2030801@ges.redhat.com> <20020816182141.GJ906@gnat.com> <20020816230524.GT906@gnat.com> <3D5D875F.6050405@ges.redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="WYTEVAkct0FjGQmd" Content-Disposition: inline In-Reply-To: <3D5D875F.6050405@ges.redhat.com> User-Agent: Mutt/1.4i X-SW-Source: 2002-08/txt/msg00479.txt.bz2 --WYTEVAkct0FjGQmd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1368 Following Andrew's suggestion, here is a revised patch to provide software single stepping on alpha-osf1, plus fix all the quirks that appeared after the switch. I know the alpha-osf1-tdep.c change is approved, but since I haven't committed it yet, I am including it in this patch for completeness. No regression on alpha-osf1 (SW single step enabled) and on x86-linux (sw single step disabled): 2002-07-18 Joel Brobecker * alpha-osf1-tdep.c (alpha_osf1_init_abi): Unfortunately, procfs appears to be broken when debugging on multi-processor machines. So enable software single stepping in order to avoid using the procfs interface to do next/step operations, using internal breakpoints instead. * infrun.c (handle_inferior_event): Readjust the stop_pc by DECR_PC_AFTER_BREAK when hitting a single step breakpoint, to make this pc address equal to the value it would have if the system stepping capability was used. Also set a new flag used to ensure that we don't readjust the PC one more time later. * breakpoint.c (bpstat_stop_status): Do not adjust the PC address by DECR_PC_AFTER_BREAK when software single step is in use for this architecture, as this has already been taken care of in handle_inferior_event(). -- Joel --WYTEVAkct0FjGQmd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sw_single_step.diff" Content-length: 4935 Index: infrun.c =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.66 diff -c -3 -p -r1.66 infrun.c *** infrun.c 17 Aug 2002 00:16:54 -0000 1.66 --- infrun.c 17 Aug 2002 00:49:19 -0000 *************** handle_inferior_event (struct execution_ *** 1408,1413 **** --- 1408,1414 ---- { CORE_ADDR tmp; int stepped_after_stopped_by_watchpoint; + int sw_single_step_trap_p = 0; /* Cache the last pid/waitstatus. */ target_last_wait_ptid = ecs->ptid; *************** handle_inferior_event (struct execution_ *** 1888,1893 **** --- 1889,1906 ---- } else if (SOFTWARE_SINGLE_STEP_P () && singlestep_breakpoints_inserted_p) { + /* Readjust the stop_pc as it is off by DECR_PC_AFTER_BREAK + compared to the value it would have if the system stepping + capability was used. This allows the rest of the code in + this function to use this address without having to worry + whether software single step is in use or not. */ + if (DECR_PC_AFTER_BREAK) + { + stop_pc -= DECR_PC_AFTER_BREAK; + write_pc_pid (stop_pc, ecs->ptid); + } + + sw_single_step_trap_p = 1; ecs->random_signal = 0; } } *************** handle_inferior_event (struct execution_ *** 2111,2124 **** (&stop_pc, /* Pass TRUE if our reason for stopping is something other than hitting a breakpoint. We do this by checking that 1) stepping is going on and 2) we didn't hit a breakpoint in a signal handler without an intervening stop in sigtramp, which is detected by a new stack pointer value below any usual function calling stack adjustments. */ ! (currently_stepping (ecs) ! && prev_pc != stop_pc - DECR_PC_AFTER_BREAK ! && !(step_range_end ! && INNER_THAN (read_sp (), (step_sp - 16))))); /* Following in case break condition called a function. */ stop_print_frame = 1; --- 2124,2139 ---- (&stop_pc, /* Pass TRUE if our reason for stopping is something other than hitting a breakpoint. We do this by checking that + either we detected earlier a software single step trap or 1) stepping is going on and 2) we didn't hit a breakpoint in a signal handler without an intervening stop in sigtramp, which is detected by a new stack pointer value below any usual function calling stack adjustments. */ ! sw_single_step_trap_p ! || (currently_stepping (ecs) ! && prev_pc != stop_pc - DECR_PC_AFTER_BREAK ! && !(step_range_end ! && INNER_THAN (read_sp (), (step_sp - 16))))); /* Following in case break condition called a function. */ stop_print_frame = 1; Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.79 diff -c -3 -p -r1.79 breakpoint.c *** breakpoint.c 16 Aug 2002 15:37:54 -0000 1.79 --- breakpoint.c 17 Aug 2002 00:49:20 -0000 *************** bpstat_stop_status (CORE_ADDR *pc, int n *** 2429,2436 **** trace/singlestep trap event, we would not want to subtract DECR_PC_AFTER_BREAK from the PC. */ ! bp_addr = *pc - (not_a_sw_breakpoint && !SOFTWARE_SINGLE_STEP_P () ? ! 0 : DECR_PC_AFTER_BREAK); ALL_BREAKPOINTS_SAFE (b, temp) { --- 2429,2435 ---- trace/singlestep trap event, we would not want to subtract DECR_PC_AFTER_BREAK from the PC. */ ! bp_addr = *pc - (not_a_sw_breakpoint ? 0 : DECR_PC_AFTER_BREAK); ALL_BREAKPOINTS_SAFE (b, temp) { Index: alpha-osf1-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/alpha-osf1-tdep.c,v retrieving revision 1.5 diff -c -3 -p -r1.5 alpha-osf1-tdep.c *** alpha-osf1-tdep.c 21 May 2002 15:36:02 -0000 1.5 --- alpha-osf1-tdep.c 17 Aug 2002 00:49:20 -0000 *************** alpha_osf1_init_abi (struct gdbarch_info *** 58,63 **** --- 58,67 ---- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); set_gdbarch_pc_in_sigtramp (gdbarch, alpha_osf1_pc_in_sigtramp); + /* The next/step support via procfs on OSF1 is broken when running + on multi-processor machines. We need to use software single stepping + instead. */ + set_gdbarch_software_single_step (gdbarch, alpha_software_single_step); tdep->skip_sigtramp_frame = alpha_osf1_skip_sigtramp_frame; tdep->sigcontext_addr = alpha_osf1_sigcontext_addr; --WYTEVAkct0FjGQmd--