mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-03 21:34:46 +08:00
Fix for incorrect breakpoint set in case of flang compiled binary
Currently, GDB is not able to set a breakpoint at subprogram post prologue for flang generated binaries. This is due to clang having two line notes one before and another after the prologue. Now the end of prologue is determined using symbol table, which was the way for clang generated binaries already. Since clang and flang both share same back-end it is true for flang as well. gdb/ChangeLog * amd64-tdep.c (amd64_skip_prologue): Using symbol table to find the end of prologue for flang compiled binaries. * arm-tdep.c (arm_skip_prologue): Likewise. * i386-tdep.c (i386_skip_prologue): Likewise. * producer.c (producer_is_llvm): New function. (producer_parsing_tests): Added new tests for clang/flang. * producer.h (producer_is_llvm): New declaration. gdb/testsuite/ChangeLog * gdb.fortran/vla-type.exp: Skip commands not required for the Flang compiled binaries after prologue fix.
This commit is contained in:
@ -1,3 +1,13 @@
|
||||
2020-08-19 Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
|
||||
|
||||
* amd64-tdep.c (amd64_skip_prologue): Using symbol table
|
||||
to find the end of prologue for flang compiled binaries.
|
||||
* arm-tdep.c (arm_skip_prologue): Likewise.
|
||||
* i386-tdep.c (i386_skip_prologue): Likewise.
|
||||
* producer.c (producer_is_llvm): New function.
|
||||
(producer_parsing_tests): Added new tests for clang/flang.
|
||||
* producer.h (producer_is_llvm): New declaration.
|
||||
|
||||
2020-08-18 Simon Marchi <simon.marchi@efficios.com>
|
||||
|
||||
* linux-nat.c (linux_nat_debug_printf): New function.
|
||||
|
@ -2547,12 +2547,13 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
|
||||
= skip_prologue_using_sal (gdbarch, func_addr);
|
||||
struct compunit_symtab *cust = find_pc_compunit_symtab (func_addr);
|
||||
|
||||
/* Clang always emits a line note before the prologue and another
|
||||
one after. We trust clang to emit usable line notes. */
|
||||
/* LLVM backend (Clang/Flang) always emits a line note before the
|
||||
prologue and another one after. We trust clang to emit usable
|
||||
line notes. */
|
||||
if (post_prologue_pc
|
||||
&& (cust != NULL
|
||||
&& COMPUNIT_PRODUCER (cust) != NULL
|
||||
&& startswith (COMPUNIT_PRODUCER (cust), "clang ")))
|
||||
&& producer_is_llvm (COMPUNIT_PRODUCER (cust))))
|
||||
return std::max (start_pc, post_prologue_pc);
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,8 @@
|
||||
#include "record-full.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "producer.h"
|
||||
|
||||
#if GDB_SELF_TEST
|
||||
#include "gdbsupport/selftest.h"
|
||||
#endif
|
||||
@ -1351,7 +1353,7 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
|
||||
&& (cust == NULL
|
||||
|| COMPUNIT_PRODUCER (cust) == NULL
|
||||
|| startswith (COMPUNIT_PRODUCER (cust), "GNU ")
|
||||
|| startswith (COMPUNIT_PRODUCER (cust), "clang ")))
|
||||
|| producer_is_llvm (COMPUNIT_PRODUCER (cust))))
|
||||
return post_prologue_pc;
|
||||
|
||||
if (post_prologue_pc != 0)
|
||||
|
@ -65,6 +65,7 @@
|
||||
#include <ctype.h>
|
||||
#include <algorithm>
|
||||
#include <unordered_set>
|
||||
#include "producer.h"
|
||||
|
||||
/* Register names. */
|
||||
|
||||
@ -1847,12 +1848,13 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
|
||||
= skip_prologue_using_sal (gdbarch, func_addr);
|
||||
struct compunit_symtab *cust = find_pc_compunit_symtab (func_addr);
|
||||
|
||||
/* Clang always emits a line note before the prologue and another
|
||||
one after. We trust clang to emit usable line notes. */
|
||||
/* LLVM backend (Clang/Flang) always emits a line note before the
|
||||
prologue and another one after. We trust clang to emit usable
|
||||
line notes. */
|
||||
if (post_prologue_pc
|
||||
&& (cust != NULL
|
||||
&& COMPUNIT_PRODUCER (cust) != NULL
|
||||
&& startswith (COMPUNIT_PRODUCER (cust), "clang ")))
|
||||
&& producer_is_llvm (COMPUNIT_PRODUCER (cust))))
|
||||
return std::max (start_pc, post_prologue_pc);
|
||||
}
|
||||
|
||||
|
@ -125,6 +125,15 @@ producer_is_icc (const char *producer, int *major, int *minor)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* See producer.h. */
|
||||
|
||||
bool
|
||||
producer_is_llvm (const char *producer)
|
||||
{
|
||||
return ((producer != NULL) && (startswith (producer, "clang ")
|
||||
|| startswith (producer, " F90 Flang ")));
|
||||
}
|
||||
|
||||
#if defined GDB_SELF_TEST
|
||||
namespace selftests {
|
||||
namespace producer {
|
||||
@ -203,6 +212,22 @@ Version 18.0 Beta";
|
||||
SELF_CHECK (producer_is_gcc (gnu_exp, &major, &minor)
|
||||
&& major == 5 && minor == 0);
|
||||
}
|
||||
|
||||
{
|
||||
static const char clang_llvm_exp[] = "clang version 12.0.0 (CLANG: bld#8)";
|
||||
int major = 0, minor = 0;
|
||||
SELF_CHECK (!producer_is_icc (clang_llvm_exp, NULL, NULL));
|
||||
SELF_CHECK (!producer_is_gcc (clang_llvm_exp, &major, &minor));
|
||||
SELF_CHECK (producer_is_llvm (clang_llvm_exp));
|
||||
}
|
||||
|
||||
{
|
||||
static const char flang_llvm_exp[] = " F90 Flang - 1.5 2017-05-01";
|
||||
int major = 0, minor = 0;
|
||||
SELF_CHECK (!producer_is_icc (flang_llvm_exp, NULL, NULL));
|
||||
SELF_CHECK (!producer_is_gcc (flang_llvm_exp, &major, &minor));
|
||||
SELF_CHECK (producer_is_llvm (flang_llvm_exp));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,4 +52,8 @@ extern int producer_is_gcc (const char *producer, int *major, int *minor);
|
||||
running on Intel(R) 64, Version 18.0 Beta ....". */
|
||||
extern bool producer_is_icc (const char *producer, int *major, int *minor);
|
||||
|
||||
/* Returns true if the given PRODUCER string is LLVM (clang/flang) or
|
||||
false otherwise.*/
|
||||
extern bool producer_is_llvm (const char *producer);
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,8 @@
|
||||
2020-08-19 Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
|
||||
|
||||
* gdb.fortran/vla-type.exp: Skip commands not required for
|
||||
the Flang compiled binaries after prologue fix.
|
||||
|
||||
2020-08-17 Tom de Vries <tdevries@suse.de>
|
||||
Tom Tromey <tromey@adacore.com>
|
||||
|
||||
|
@ -33,8 +33,12 @@ set int [fortran_int4]
|
||||
|
||||
# Check if not allocated VLA in type does not break
|
||||
# the debugger when accessing it.
|
||||
gdb_breakpoint [gdb_get_line_number "before-allocated"]
|
||||
gdb_continue_to_breakpoint "before-allocated"
|
||||
# break main for Flang compiler already breaks here
|
||||
if ![test_compiler_info "clang-*"] {
|
||||
gdb_breakpoint [gdb_get_line_number "before-allocated"]
|
||||
gdb_continue_to_breakpoint "before-allocated"
|
||||
}
|
||||
|
||||
gdb_test "print twov" " = \\\( ivla1 = <not allocated>, ivla2 = <not allocated> \\\)" \
|
||||
"print twov before allocated"
|
||||
gdb_test "print twov%ivla1" " = <not allocated>" \
|
||||
|
Reference in New Issue
Block a user