This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: PING^8 Re: [RFC] Have an option to tell GDB to detect and possibly handle mismatched exec-files.
- From: Tom Tromey <tom at tromey dot com>
- To: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- Cc: Pedro Alves <palves at redhat dot com>, gdb-patches at sourceware dot org, Tom Tromey <tom at tromey dot com>
- Date: Fri, 13 Dec 2019 15:09:21 -0700
- Subject: Re: PING^8 Re: [RFC] Have an option to tell GDB to detect and possibly handle mismatched exec-files.
- References: <20190318225822.4820-1-philippe.waroquiers@skynet.be> <87ef72x1a4.fsf@tromey.com> <1553106871.6197.31.camel@skynet.be> <1554323097.1854.9.camel@skynet.be> <1554898198.1446.4.camel@skynet.be> <104bcc8b-fd91-449b-c02d-8c839b3c2a1a@redhat.com> <057aecdb8444089356d80ac04848a81ed2948890.camel@skynet.be> <ace82eabf35c113a858259a5471f17e749577c74.camel@skynet.be>
>>>>> "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:
Philippe> Ping ?
Philippe> (attaching a patch rebased on recent master)
I'm sorry for the extreme delay on this.
I read through the thread a bit, and I looked briefly at the other
threads in the past. I didn't read those exhaustively though.
Philippe> This patch series implements a new option:
Philippe> (gdb) apropos exec-file-mismatch
Philippe> set exec-file-mismatch -- Set exec-file-mismatch handling
Philippe> show exec-file-mismatch -- Show exec-file-mismatch handling
Seems reasonable.
Philippe> The same tests as above then give:
[...]
Philippe> (gdb) atta 31069
Philippe> Attaching to program: /home/philippe/valgrind/git/trunk_untouched/gdbserver_tests/sleepers, process 31069
Philippe> warning: Mismatch between current exec-file /home/philippe/valgrind/git/trunk_untouched/gdbserver_tests/sleepers
Philippe> and automatically determined exec-file /bd/home/philippe/gdb/git/build_fixes/gdb/gdb
Philippe> exec-file-mismatch handling is currently "reload"
Philippe> Load new symbol table from "/bd/home/philippe/gdb/git/build_fixes/gdb/gdb"? (y or n) y
Philippe> Reading symbols from /bd/home/philippe/gdb/git/build_fixes/gdb/gdb...
Nice.
Philippe> +enum exec_file_mismatch_mode exec_file_mismatch_mode = exec_file_mismatch_reload;
This can be "static".
Philippe> Still missing:
Philippe> ChangeLog
Philippe> NEWS
Philippe> user manual
... still needs these, but I completely understand why you put off
writing them.
Philippe> +void
Philippe> +validate_exec_file (int from_tty)
Philippe> +{
Philippe> + if (exec_file_mismatch_mode == exec_file_mismatch_off)
Philippe> + return; /* User asked to do nothing. */
Normally gdb prefers comments not to be at the end of the line like
this. It's fine to just stick them before the "if", maybe reworded
sometimes.
Philippe> + char *current_exec_file = get_exec_file (0);
Could be const.
Philippe> + /* Try to determine a filename from the process itself. */
Philippe> + char *pid_exec_file = target_pid_to_exec_file (inf->pid);
Also could be const.
Philippe> + if (strcmp (exec_file_target.c_str (), current_exec_file) != 0)
This can just use !=, because exec_file_target is a std::string.
Philippe> + {
Philippe> + warning (_("Mismatch between current exec-file %s\n"
Philippe> + "and automatically determined exec-file %s\n"
Philippe> + "exec-file-mismatch handling is currently \"%s\""),
I wonder whether the newlines are needed? And also if now this should
use %ps and styled_string and file_name_style?
What happens if the inferior exec()s something else? Also why was a
validate call required in remote.c but not in any other target?
thanks,
Tom