This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/3] print_stack_frame&friends: merge print_level, print_args and print_what.


On Fri, 30 Aug 2013 17:50:19 +0200, Pedro Alves wrote:
[...]
> --- a/gdb/bsd-kvm.c
> +++ b/gdb/bsd-kvm.c
> @@ -100,7 +100,8 @@ bsd_kvm_open (char *filename, int from_tty)
>    target_fetch_registers (get_current_regcache (), -1);
>  
>    reinit_frame_cache ();
> -  print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
> +  print_stack_frame (get_selected_frame (NULL), 0,
> +		     PF_LOCATION | PF_SRC_LINE, 1);

The "0," part is excessive, it will fail the build.


>  }
>  
>  static void
> @@ -286,7 +287,8 @@ bsd_kvm_proc_cmd (char *arg, int fromtty)
>    target_fetch_registers (get_current_regcache (), -1);
>  
>    reinit_frame_cache ();
> -  print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
> +  print_stack_frame (get_selected_frame (NULL), 0,
> +		     PF_LOCATION | PF_SRC_LINE, 1);

Likewise.


>  }
>  
>  #endif
> @@ -306,7 +308,8 @@ bsd_kvm_pcb_cmd (char *arg, int fromtty)
>    target_fetch_registers (get_current_regcache (), -1);
>  
>    reinit_frame_cache ();
> -  print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1);
> +  print_stack_frame (get_selected_frame (NULL), 0,
> +		     PF_LOCATION | PF_SRC_LINE, 1);

Likewise.


>  }
>  
>  static int
[...]
> --- a/gdb/frame.h
> +++ b/gdb/frame.h
> @@ -595,18 +595,37 @@ extern struct gdbarch *frame_unwind_arch (struct frame_info *frame);
>  extern struct gdbarch *frame_unwind_caller_arch (struct frame_info *frame);
>  
>  
> -/* Values for the source flag to be used in print_frame_info_base().  */
> +/* Bit flags to be used with print_stack_frame, print_frame_info and
> +   friends.  */
> +
>  enum print_what
>    { 
> -    /* Print only the source line, like in stepi.  */
> -    SRC_LINE = -1, 
> -    /* Print only the location, i.e. level, address (sometimes)
> -       function, args, file, line, line num.  */
> -    LOCATION,
> -    /* Print both of the above.  */
> -    SRC_AND_LOC, 
> -    /* Print location only, but always include the address.  */
> -    LOC_AND_ADDRESS 
> +    /* Print the location, i.e. level (if requested), address
> +       (sometimes), function, args (if requested), file, line, line
> +       num.  */
> +    PF_LOCATION = 1 << 0,
> +
> +    /* Print frame level before the location (e.g., #0).  */
> +    PF_LOC_LEVEL = 1 << 1,
> +
> +    /* Always print address in addition to the location.  If not
> +       specified, the address is printed if there's no symtab for the
> +       location or if the location points in the middle of a
> +       statement.  */
> +    PF_LOC_ADDRESS = 1 << 2,
> +
> +    /* Print function arguments.  */
> +    PF_LOC_ARGS = 1 << 3,
> +
> +    /* Print the source line, if possible.  If not possible (e.g.,
> +       after a stepi in code that has no debug info), print the
> +       location instead.  */
> +    PF_SRC_LINE = 1 << 4,
> +
> +    /* Print address before the source line if PC points to the middle
> +       of a statement.  Only valid if PF_SRC_LINE is also
> +       specified.  */

In such case print_frame could gdb_assert that.


> +    PF_SRC_ADDRESS = 1 << 5,
>    };
>  
>  /* Allocate zero initialized memory from the frame cache obstack.
[...]
> --- a/gdb/stack.c
> +++ b/gdb/stack.c
[...]
> @@ -146,29 +146,30 @@ frame_show_address (struct frame_info *frame,
>    return get_frame_pc (frame) != sal.pc;
>  }
>  
> -/* Show or print a stack frame FRAME briefly.  The output is format
> -   according to PRINT_LEVEL and PRINT_WHAT printing the frame's
> -   relative level, function name, argument list, and file name and
> -   line number.  If the frame's PC is not at the beginning of the
> -   source line, the actual PC is printed at the beginning.  */
> +/* Show or print a stack frame FRAME briefly.  The output is formatted
> +   according to PRINT_WHAT, printing the frame's relative level,
> +   function name, argument list, file name and line number.  If the
> +   frame's PC is not at the beginning of the source line, the actual
> +   PC is printed at the beginning.  */
>  
>  void
> -print_stack_frame (struct frame_info *frame, int print_level,
> -		   enum print_what print_what,
> +print_stack_frame (struct frame_info *frame, enum print_what print_what,
>  		   int set_current_sal)
>  {
>    volatile struct gdb_exception e;
>  
> -  /* For mi, alway print location and address.  */
> +  /* For mi, alway print location and address, and no source line.  */
>    if (ui_out_is_mi_like_p (current_uiout))
> -    print_what = LOC_AND_ADDRESS;
> +    {
> +      print_what |= PF_LOCATION | PF_LOC_ADDRESS;
> +      print_what &= ~PF_SRC_LINE;

Why not to clear also PF_SRC_ADDRESS?


> +    }
>  
>    TRY_CATCH (e, RETURN_MASK_ERROR)
>      {
> -      int center = (print_what == SRC_LINE || print_what == SRC_AND_LOC);
> +      int center = (print_what & PF_SRC_LINE) != 0;
>  
> -      print_frame_info (frame, print_level, print_what, 1 /* print_args */,
> -			set_current_sal);
> +      print_frame_info (frame, print_what | PF_LOC_ARGS, set_current_sal);
>        if (set_current_sal)
>  	set_current_sal_from_frame (frame, center);
>      }


Thanks,
Jan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]