From 0c1bcd23274e9f465dc43eda4fc467150631f824 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 28 Jun 2021 15:28:26 -0400 Subject: gdb: convert obj_section macros to methods Convert these three macros to methods of obj_section. The problem fixed by the following patch is caused by an out of bound access of the objfile::section_offsets vector. Since this is deep in macros, we don't get a clear backtrace and it's difficult to debug. Changing that to methods means we can step in them and break on them. Because their implementation requires knowing about struct objfile, move struct obj_section below struct objfile in objfiles.h. The obj_section_offset was used in one place as an lvalue to set offsets, in machoread.c. Replace that with a set_offset method. Add the objfile::section_offset and objfile::set_section_offset methods to improve encapsulation (reduce other objects poking into struct objfile's internals). gdb/ChangeLog: * objfiles.h (struct obj_section): Move down. : New. (obj_section_offset, obj_section_addr, obj_section_endaddr), replace all users to use obj_section methods. (struct objfile) : New. Change-Id: I97e8fcae93ab2353fbdadcb4a5ec10d7949a7334 --- gdb/machoread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gdb/machoread.c') diff --git a/gdb/machoread.c b/gdb/machoread.c index 17aa9ce..a0f0307 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -926,7 +926,7 @@ macho_symfile_offsets (struct objfile *objfile, if (bfd_sect_name == addrs[i].name) { - obj_section_offset (osect) = addrs[i].addr; + osect->set_offset (addrs[i].addr); break; } } -- cgit v1.1