diff options
Diffstat (limited to 'gdb/dwarf2/cu.c')
-rw-r--r-- | gdb/dwarf2/cu.c | 108 |
1 files changed, 92 insertions, 16 deletions
diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c index 1029b24..86b77f5 100644 --- a/gdb/dwarf2/cu.c +++ b/gdb/dwarf2/cu.c @@ -1,6 +1,6 @@ /* DWARF CU data structure - Copyright (C) 2021-2024 Free Software Foundation, Inc. + Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -21,27 +21,35 @@ #include "dwarf2/read.h" #include "objfiles.h" #include "filenames.h" +#include "producer.h" #include "gdbsupport/pathstuff.h" /* Initialize dwarf2_cu to read PER_CU, in the context of PER_OBJFILE. */ -dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile) +dwarf2_cu::dwarf2_cu (dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile) : per_cu (per_cu), per_objfile (per_objfile), m_mark (false), has_loclist (false), - checked_producer (false), - producer_is_gxx_lt_4_6 (false), - producer_is_gcc_lt_4_3 (false), - producer_is_gcc_11 (false), - producer_is_icc (false), - producer_is_icc_lt_14 (false), - producer_is_codewarrior (false), - producer_is_clang (false), - producer_is_gas_lt_2_38 (false), - producer_is_gas_2_39 (false), - producer_is_gas_ge_2_40 (false), + m_checked_producer (false), + m_producer_is_gxx_lt_4_6 (false), + m_producer_is_gcc_lt_4_5 (false), + m_producer_is_gcc_lt_4_3 (false), + m_producer_is_gcc_ge_4 (false), + m_producer_is_gcc_11 (false), + m_producer_is_gcc (false), + m_producer_is_icc (false), + m_producer_is_icc_lt_14 (false), + m_producer_is_codewarrior (false), + m_producer_is_clang (false), + m_producer_is_gas_lt_2_38 (false), + m_producer_is_gas_2_39 (false), + m_producer_is_gas_ge_2_40 (false), + m_producer_is_realview (false), + m_producer_is_xlc (false), + m_producer_is_xlc_opencl (false), + m_producer_is_gf77 (false), + m_producer_is_ggo (false), processing_has_namespace_info (false) { } @@ -98,7 +106,7 @@ dwarf2_cu::start_compunit_symtab (const char *name, const char *comp_dir, const char *debugformat = debugformat_strings[this->header.version - 2]; get_builder ()->record_debugformat (debugformat); - get_builder ()->record_producer (producer); + get_builder ()->record_producer (m_producer); processing_has_namespace_info = false; @@ -132,7 +140,7 @@ dwarf2_cu::mark () m_mark = true; - for (dwarf2_per_cu_data *per_cu : m_dependencies) + for (dwarf2_per_cu *per_cu : m_dependencies) { /* cu->m_dependencies references may not yet have been ever read if QUIT aborts reading of the chain. As such @@ -161,3 +169,71 @@ dwarf2_cu::get_builder () gdb_assert_not_reached (""); } + +/* See dwarf2/cu.h. */ + +void +dwarf2_cu::set_producer (const char *producer) +{ + gdb_assert (m_producer == nullptr || strcmp (producer, m_producer) == 0); + m_producer = producer; + + int major, minor; + + if (m_producer == nullptr) + { + /* For unknown compilers expect their behavior is DWARF version + compliant. + + GCC started to support .debug_types sections by -gdwarf-4 since + gcc-4.5.x. As the .debug_types sections are missing DW_AT_producer + for their space efficiency GDB cannot workaround gcc-4.5.x -gdwarf-4 + combination. gcc-4.5.x -gdwarf-4 binaries have DW_AT_accessibility + interpreted incorrectly by GDB now - GCC PR debug/48229. */ + } + else if (::producer_is_gcc (m_producer, &major, &minor)) + { + m_producer_is_gxx_lt_4_6 = major < 4 || (major == 4 && minor < 6); + m_producer_is_gcc_lt_4_5 = major < 4 || (major == 4 && minor < 5); + m_producer_is_gcc_lt_4_3 = major < 4 || (major == 4 && minor < 3); + m_producer_is_gcc_ge_4 = major >= 4; + m_producer_is_gcc_11 = major == 11; + m_producer_is_gcc = true; + } + else if (::producer_is_icc (m_producer, &major, &minor)) + { + m_producer_is_icc = true; + m_producer_is_icc_lt_14 = major < 14; + } + else if (startswith (m_producer, "CodeWarrior S12/L-ISA")) + m_producer_is_codewarrior = true; + else if (::producer_is_clang (m_producer, &major, &minor)) + m_producer_is_clang = true; + else if (::producer_is_gas (m_producer, &major, &minor)) + { + m_producer_is_gas_lt_2_38 = major < 2 || (major == 2 && minor < 38); + m_producer_is_gas_2_39 = major == 2 && minor == 39; + m_producer_is_gas_ge_2_40 = major > 2 || (major == 2 && minor >= 40); + } + else if (::producer_is_realview (m_producer)) + m_producer_is_realview = true; + else if (startswith (m_producer, "IBM(R) XL C/C++ Advanced Edition")) + m_producer_is_xlc = true; + else if (strstr (m_producer, "IBM XL C for OpenCL") != nullptr) + m_producer_is_xlc_opencl = true; + else + { + /* For other non-GCC compilers, expect their behavior is DWARF version + compliant. */ + } + + if (m_producer != nullptr) + { + if (strstr (m_producer, "GNU F77") != nullptr) + m_producer_is_gf77 = true; + else if (strstr (m_producer, "GNU Go ") != nullptr) + m_producer_is_ggo = true; + } + + m_checked_producer = true; +} |