[1/3] Fix GDB reverse execution behavior

Message ID 0743198c95396b679bd2215a6518d9e97ffa80f5.camel@linux.ibm.com
State New
Headers
Series [1/3] Fix GDB reverse execution behavior |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Carl Love Nov. 22, 2023, 11:33 p.m. UTC
  GDB maintainers:

This patch in the series is unchanged from the previously posted
version 2 patch of patch 1 in the previous patch series.
 
Version 2, updated the compiler check and handling for gcc version 6
and earlier.  Retested on Power 10.

Per the comments on version 4 for the gdb.reverse/func-map-to-same-
line.exp, I have added support to proc gdb_compile to enable or disable
generating line information as part of the debug information.  The two
new options are column-info and no-column-info.  

This patch implements the new options for gdb_compile.

These options have been tested with patch 2 and patch 3 on PowerPC with
the GCC and clang compilers.

Please let me know if the patch is acceptable for mainline.   Thanks.

                   Carl

------------------------------------------------------------

Add gdb_compile options column-info and no-column-info

This patch adds two new options to gdb_compile to specify if the compile
should or should not generate the line table information.  The
options are supported on clang and gcc version 7 and newer.

Patch has been tested on PowerPC with both gcc and clang.
---
 gdb/testsuite/lib/gdb.exp | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
  

Comments

Luis Machado Nov. 29, 2023, 11:44 a.m. UTC | #1
On 11/22/23 23:33, Carl Love wrote:
> GDB maintainers:
> 
> This patch in the series is unchanged from the previously posted
> version 2 patch of patch 1 in the previous patch series.
>  
> Version 2, updated the compiler check and handling for gcc version 6
> and earlier.  Retested on Power 10.
> 
> Per the comments on version 4 for the gdb.reverse/func-map-to-same-
> line.exp, I have added support to proc gdb_compile to enable or disable
> generating line information as part of the debug information.  The two
> new options are column-info and no-column-info.  
> 
> This patch implements the new options for gdb_compile.
> 
> These options have been tested with patch 2 and patch 3 on PowerPC with
> the GCC and clang compilers.
> 
> Please let me know if the patch is acceptable for mainline.   Thanks.
> 
>                    Carl
> 
> ------------------------------------------------------------
> 
> Add gdb_compile options column-info and no-column-info
> 
> This patch adds two new options to gdb_compile to specify if the compile
> should or should not generate the line table information.  The
> options are supported on clang and gcc version 7 and newer.
> 
> Patch has been tested on PowerPC with both gcc and clang.
> ---
>  gdb/testsuite/lib/gdb.exp | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 63885860795..a63394d5cc0 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -5150,6 +5150,8 @@ proc quote_for_host { args } {
>  #     debug information
>  #   - text_segment=addr: Tell the linker to place the text segment at ADDR.
>  #   - build-id: Ensure the final binary includes a build-id.
> +#   - column-info/no-column-info: Enable/Disable generation of column table
> +#     information.
>  #
>  # And here are some of the not too obscure options understood by DejaGnu that
>  # influence the compilation:
> @@ -5359,6 +5361,38 @@ proc gdb_compile {source dest type options} {
>              } else {
>                  error "Don't know how to handle text_segment option."
>              }
> +	} elseif { $opt == "column-info" } {
> +	    # If GCC or clang does not support column-info, compilation
> +	    # will fail and the usupported column-info option will be
> +	    # reported as such.
> +	    if {[test_compiler_info {gcc-*}]} {
> +		lappend new_options "additional_flags=-gcolumn-info"
> +
> +	    } elseif {[test_compiler_info {clang-*}]} {
> +		lappend new_options "additional_flags=-gcolumn-info"
> +
> +	    } else {
> +		error "Option gcolumn-info option not supported by compiler."

s/Option gcolumn-info option/Option gcolumn-info

> +	    }
> +
> +	} elseif { $opt == "no-column-info" } {
> +	    if {[test_compiler_info {gcc-*}]} {
> +		if {[test_compiler_info {gcc-[1-6]-*}]} {
> +		    # In this case, don't add the compile line option and
> +		    # the result will be the same as using no-column-info
> +		    # on a version that supports the option.
> +		    warning "gdb_compile option no-column-info not supported, ignoring."
> +		} else {
> +		    lappend new_options "additional_flags=-gno-column-info"
> +		}
> +
> +	    } elseif {[test_compiler_info {clang-*}]} {
> +		lappend new_options "additional_flags=-gno-column-info"
> +
> +	    } else {
> +		error "Option gno-column-info option not supported by compiler."

s/Option gno-column-info option/Option gno-column-info

> +	    }
> +
>          } else {
>              lappend new_options $opt
>          }

Other LGTM. I have tested this on aarch64-linux and arm-linux with gcc. Works fine.

Tested-By: Luis Machado <luis.machado@arm.com>
Reviewed-By: Luis Machado <luis.machado@arm.com>
  
Carl Love Nov. 29, 2023, 4:30 p.m. UTC | #2
Luis:

On Wed, 2023-11-29 at 11:44 +0000, Luis Machado wrote:
> > +         } else {
> > +             error "Option gcolumn-info option not supported by
> > compiler."
> 
> s/Option gcolumn-info option/Option gcolumn-info
fixed
> 
> > +         }
> > +
> > +     } elseif { $opt == "no-column-info" } {
> > +         if {[test_compiler_info {gcc-*}]} {
> > +             if {[test_compiler_info {gcc-[1-6]-*}]} {
> > +                 # In this case, don't add the compile line option
> > and
> > +                 # the result will be the same as using no-column-
> > info
> > +                 # on a version that supports the option.
> > +                 warning "gdb_compile option no-column-info not
> > supported, ignoring."
> > +             } else {
> > +                 lappend new_options "additional_flags=-gno-
> > column-info"
> > +             }
> > +
> > +         } elseif {[test_compiler_info {clang-*}]} {
> > +             lappend new_options "additional_flags=-gno-column-
> > info"
> > +
> > +         } else {
> > +             error "Option gno-column-info option not supported by
> > compiler."
> 
> s/Option gno-column-info option/Option gno-column-info
fixed

I made the fixes to the patches.  The changes are fairly trivial so let
s see if anyone else has any comments to add before sending out another
version.  

Thanks for reviewing and testing.

                        Carl
  
Luis Machado Nov. 29, 2023, 4:38 p.m. UTC | #3
On 11/29/23 16:30, Carl Love wrote:
> Luis:
> 
> On Wed, 2023-11-29 at 11:44 +0000, Luis Machado wrote:
>>> +         } else {
>>> +             error "Option gcolumn-info option not supported by
>>> compiler."
>>
>> s/Option gcolumn-info option/Option gcolumn-info
> fixed
>>
>>> +         }
>>> +
>>> +     } elseif { $opt == "no-column-info" } {
>>> +         if {[test_compiler_info {gcc-*}]} {
>>> +             if {[test_compiler_info {gcc-[1-6]-*}]} {
>>> +                 # In this case, don't add the compile line option
>>> and
>>> +                 # the result will be the same as using no-column-
>>> info
>>> +                 # on a version that supports the option.
>>> +                 warning "gdb_compile option no-column-info not
>>> supported, ignoring."
>>> +             } else {
>>> +                 lappend new_options "additional_flags=-gno-
>>> column-info"
>>> +             }
>>> +
>>> +         } elseif {[test_compiler_info {clang-*}]} {
>>> +             lappend new_options "additional_flags=-gno-column-
>>> info"
>>> +
>>> +         } else {
>>> +             error "Option gno-column-info option not supported by
>>> compiler."
>>
>> s/Option gno-column-info option/Option gno-column-info
> fixed
> 
> I made the fixes to the patches.  The changes are fairly trivial so let
> s see if anyone else has any comments to add before sending out another
> version.  
> 
> Thanks for reviewing and testing.
> 
>                         Carl 
> 

For what's worth, I don't think it needs another version for these small fixes.
  

Patch

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 63885860795..a63394d5cc0 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5150,6 +5150,8 @@  proc quote_for_host { args } {
 #     debug information
 #   - text_segment=addr: Tell the linker to place the text segment at ADDR.
 #   - build-id: Ensure the final binary includes a build-id.
+#   - column-info/no-column-info: Enable/Disable generation of column table
+#     information.
 #
 # And here are some of the not too obscure options understood by DejaGnu that
 # influence the compilation:
@@ -5359,6 +5361,38 @@  proc gdb_compile {source dest type options} {
             } else {
                 error "Don't know how to handle text_segment option."
             }
+	} elseif { $opt == "column-info" } {
+	    # If GCC or clang does not support column-info, compilation
+	    # will fail and the usupported column-info option will be
+	    # reported as such.
+	    if {[test_compiler_info {gcc-*}]} {
+		lappend new_options "additional_flags=-gcolumn-info"
+
+	    } elseif {[test_compiler_info {clang-*}]} {
+		lappend new_options "additional_flags=-gcolumn-info"
+
+	    } else {
+		error "Option gcolumn-info option not supported by compiler."
+	    }
+
+	} elseif { $opt == "no-column-info" } {
+	    if {[test_compiler_info {gcc-*}]} {
+		if {[test_compiler_info {gcc-[1-6]-*}]} {
+		    # In this case, don't add the compile line option and
+		    # the result will be the same as using no-column-info
+		    # on a version that supports the option.
+		    warning "gdb_compile option no-column-info not supported, ignoring."
+		} else {
+		    lappend new_options "additional_flags=-gno-column-info"
+		}
+
+	    } elseif {[test_compiler_info {clang-*}]} {
+		lappend new_options "additional_flags=-gno-column-info"
+
+	    } else {
+		error "Option gno-column-info option not supported by compiler."
+	    }
+
         } else {
             lappend new_options $opt
         }