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: [RFC][PATCH] fix gdb segv when objfile can't be opened


On 2017-10-23 07:19 PM, Mike Gulick wrote:
> Here is a new version of the patch.  It changes the following from the original
> patch:
> 
> 1) It adds a testsuite which locks down:
>   a) The stack frame is printed when the breakpoint is hit
>   b) 'next' runs without causing a segv
> 2) No longer set descriptor->size in gdb_bfd_map_section when an error is hit.
>    It doesn't look like this is needed as gdb_bfd_map_section is the only place
>    that consumes that descriptor->size field.
> 3) Update the description in gdb_bfd.h to indicate that if there is an error
>    mapping the section, a warning is generated, *SIZE is set to 0, and NULL is
>    returned.
> 
> I considered catching the error in the caller of gdb_bfd_map_section, which is
> dwarf2_read_section in dwarf2read.c.  It didn't seem to make any more sense to
> catch the error here than it would directly in gdb_bfd_map_section.  If
> anything, it would make more sense to catch the error in the caller of
> dwarf2_read_section, which in this case is dwarf2_get_section_info.  However
> there are many callers of dwarf2_read_section.  It doesn't make sense to force
> all of them to add a TRY/CATCH around calling dwarf2_read_section.
> 
> Please let me know thoughts/feedback.
> 
> Also see the note in the test case about not being able to make 'shlib=...'
> work when compiling a shared library that links against another shared
> library.  The workaround I used is kind of ugly.

Hi Mike,

I started looking at your patch and thought I would take a look at this problem.
The problem seems to be that gdb_compile_shlib builds the shared library in two
steps:

  .c -> .o -> .so

because it's not possible to do it in one pass.  As of today, if you pass an
shlib= option to gdb_compile_shlib, it will be passed to both compilation steps,
which means Dejagnu will pass the path to lib1.so while compiling the .c to a .o,
which makes gcc complain like this:

  warning: .../solib-vanish-lib2.so: linker input file unused because linking not done

I think the solution would be not to pass shlib= for this step, only for the final
linking.  I'll try to write a patch about this.

Simon


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