[RFA/controversial] move bp by line number past the prologue

Joel Brobecker brobecker@gnat.com
Fri Aug 30 17:55:00 GMT 2002


> 2002-08-30  Jim Ingham <jingham@apple.com>
> 
>         * linespec.c (decode_line_1): Skip the function prologue if
>         funfirstline is set, unless adjust_break_after_prologue is
>         unset by the user. Changes the behavior of the break command
>         to skip the function prologue when breaking by line number.
> 
> 2002-08-30  Joel Brobecker  <brobecker@gnat.com>
> 
>         * linespec.c (adjust_break_after_prologue): New static variable.
>         (_initialize_linespec): New function.
> 
>         * Makefile.in: Update the dependencies for linespec.c

KevinB rightfully pointed out that the patch was missing...

-- 
Joel
-------------- next part --------------
Index: linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.21
diff -c -3 -p -r1.21 linespec.c
*** linespec.c	11 May 2002 22:46:19 -0000	1.21
--- linespec.c	30 Aug 2002 18:44:03 -0000
***************
*** 30,35 ****
--- 30,40 ----
  #include "value.h"
  #include "completer.h"
  #include "cp-abi.h"
+ #include "gdbcmd.h"
+ 
+ /* local variables */
+ 
+ static int adjust_break_after_prologue = 1;
  
  /* Prototype for one function in parser-defs.h,
     instead of including that entire file. */
*************** extern char *operator_chars (char *, cha
*** 42,47 ****
--- 47,54 ----
  
  /* Prototypes for local functions */
  
+ void _initialize_linespec (void);
+ 
  static void cplusplus_error (const char *name, const char *fmt, ...) ATTR_FORMAT (printf, 2, 3);
  
  static int total_number_of_methods (struct type *type);
*************** decode_line_1 (char **argptr, int funfir
*** 1067,1073 ****
--- 1074,1105 ----
        if (val.symtab == 0)
  	val.symtab = s;
  
+       /* If funfirstline is set, we need to look up the function
+        containing the line, and move past the prologue. This behavior
+        can be deactivated by unsetting adjust-break-after-prologue.  */
+ 
        val.pc = 0;
+       if (funfirstline && adjust_break_after_prologue)
+       {
+         CORE_ADDR pc = 0;
+ 
+         if (find_line_pc (val.symtab, val.line, &pc))
+           {
+             struct symbol *func_sym;
+             struct symtab_and_line sal;
+             
+             func_sym = find_pc_function (pc);
+             if (func_sym)
+               {
+                 sal = find_function_start_sal (func_sym, 1);
+                 /* Don't move the line, just set the pc
+                    to the right place. */
+                 if (val.line <= sal.line)
+                   val.pc = sal.pc;
+               }
+           }
+       }
+ 
        values.sals = (struct symtab_and_line *)
  	xmalloc (sizeof (struct symtab_and_line));
        values.sals[0] = val;
*************** minimal_symbol_found:		/* We also jump h
*** 1267,1270 ****
--- 1299,1317 ----
  
    error ("Function \"%s\" not defined.", copy);
    return values;		/* for lint */
+ }
+ 
+ void
+ _initialize_linespec (void)
+ {
+   struct cmd_list_element *c;
+ 
+   c = add_set_cmd ("adjust-break-after-prologue", class_breakpoint,
+                    var_boolean, (char *) &adjust_break_after_prologue,
+                    "Set whether GDB should adjust the location of a \
+ breakpoint past function prologues when computing its address from a line \
+ number.", &setlist);
+ 
+   add_show_from_set (c, &showlist);
+ 
  }
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.236
diff -c -3 -p -r1.236 Makefile.in
*** Makefile.in	14 Aug 2002 18:13:30 -0000	1.236
--- Makefile.in	30 Aug 2002 18:44:04 -0000
*************** symtab.o: symtab.c $(defs_h) $(symtab_h)
*** 2233,2239 ****
  
  linespec.o: linespec.c $(linespec_h) $(defs_h) $(frame_h) $(value_h) \
  	$(objfiles_h) $(symfile_h) $(completer_h) $(symtab_h) \
! 	$(demangle_h) $(command_h) $(cp_abi_h)
  
  macroexp.o: macroexp.c $(defs_h) $(gdb_obstack_h) $(bcache_h) $(macrotab_h) \
  	$(macroexp_h) $(gdb_assert_h)
--- 2233,2239 ----
  
  linespec.o: linespec.c $(linespec_h) $(defs_h) $(frame_h) $(value_h) \
  	$(objfiles_h) $(symfile_h) $(completer_h) $(symtab_h) \
! 	$(demangle_h) $(command_h) $(cp_abi_h) $(gdbcmd_h)
  
  macroexp.o: macroexp.c $(defs_h) $(gdb_obstack_h) $(bcache_h) $(macrotab_h) \
  	$(macroexp_h) $(gdb_assert_h)


More information about the Gdb-patches mailing list