Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] ia64: Fix breakpoints memory shadow
Date: Thu, 13 Nov 2008 14:27:00 -0000	[thread overview]
Message-ID: <20081113053100.GL5112@adacore.com> (raw)
In-Reply-To: <20081111131726.GA3272@host0.dyn.jankratochvil.net>

> According to ISO C90 6.5.7 such a static array is (was) initialized to zeroes.

Ah - I actually looked at the draft document I have, but I cannot
seem to be able to navigate this document just yet, so I didn't
find anything that confirmed this. From outside, it did look like
the logic was broken, which is why I pointed this out. As you said,
it was already broken before, so thanks for fixing it.

> 2008-11-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	Fix automatic restoration of breakpoints memory for ia64.
> 	* ia64-tdep.c: New #if check on BREAKPOINT_MAX vs. BUNDLE_LEN.  
> 	(ia64_memory_insert_breakpoint): New comment part for SHADOW_CONTENTS
> 	content.  Remova variable instr.  New variable cleanup.  Force
                  ^^^^^^ Typo: Remove

> 	automatic breakpoints restoration.  PLACED_SIZE and SHADOW_LEN are now
> 	set larger, to BUNDLE_LEN - 2.  Variable `bundle' type update.
> 	(ia64_memory_remove_breakpoint): Rename variables bundle to bundle_mem
> 	and instr to instr_saved.  New variables bundle_saved and
> 	instr_breakpoint.  Comment new reasons why we need to disable automatic
> 	restoration of breakpoints.  Assert PLACED_SIZE and SHADOW_LEN.  New
> 	check of the original memory content.
> 	(ia64_breakpoint_from_pc): Implement the emulation of permanent
> 	breakpoints compatible with current bp_loc_is_permanent.
> 	(template_encoding_table): Make it `const'.
> 	* breakpoint.c (bp_loc_is_permanent): Support unsupported software
> 	breakpoints.  New variables `cleanup' and `retval' to protect
> 	target_read_memory by make_show_memory_breakpoints_cleanup.

For the future, I think that the second sentence is unnecessarily
precise, so you can save yourself a little bit. But that's OK too.

> 	* monitor.c (monitor_insert_breakpoint): Remove unused variable `bp'.

This one should really have been a separate change. It also qualifies
as obvious, so you could have checked it in immediately.

> +/* Our caller bp_loc_is_permanent uses plain memcmp expecting byte ranges of
> +   the instructions.  We provide the extended range as described for
> +   ia64_memory_insert_breakpoint simulating a placed breakpoint there - memcmp
> +   will return true iff there was already a breakpoint (and so we returned the
> +   original memory).  We just take care of preserving the `break' instruction
> +   21-bit (or 62-bit) parameter as the memcmp match would fail otherwise.  */

I don't think it's a good idea to refer to the caller in the description
of a routine. We might add more in the future...  What you could say is
that this function implements the semantics of the breakpoint_from_pc
gdbarch method, and then proceed to explain the way you did why this
function is tricky to implement on ia64.

> +  /* It may be currently unreachable breakpoint which is never permanent.  */
> +  if (val != 0)
> +    return NULL;

I am not sure I understand the relationship between the fact that
the memory is unreachable (do we know when this might happen?) and
the conclusion that you are reaching. I tend to have simplistic
views of the real situation, so this may be a little too simple
to be acurate, but I would have just said that we need to be able
to read the original memory location to produce the breakpoint
sequence.

> +  /* We need to keep the possible `break' instruction parameter value intact.
> +     Opcode with cleared all the bits (except the parameter value) is `break'.

It took me a long while to understand this, and it's probably because
it's getting for me. But could it also be due to pure English. IIUC,
I propose instead (in my own broken English ;-):

  A break instruction has its all its opcode bits cleared except for
  the parameter value.

> +     For L+X slot pair we are at the X slot (3) so we should not touch the
> +     L slot - the upper 41 bits of the parameter.  */

Not being extremely familiar with the ia64 chip, I think I'll trust you
with how the above translates into the code below:

> +  instr_fetched = slotN_contents (bundle, slotnum);
> +  instr_fetched &= 0x1003ffffc0;
> +  replace_slotN_contents (bundle, instr_fetched, slotnum);

> +# This is a testcase specifically for the `start' GDB command.  For regular
> +# stop-in-main goal in the testcases please use `runto_main' instead.
                                       ^^^^^^^^^^^^
Can you just change the wording to "consider using"? It's softer.
There might be some cases in the future where gdb_start_cmd might
be more useful than using runto_main.

Overall, the patch looks good is and is pre-approved once the
observations above are addressed.

Thanks,
-- 
Joel


  reply	other threads:[~2008-11-13  5:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-28 17:52 Jan Kratochvil
2008-10-30  1:51 ` Joel Brobecker
2008-10-31  0:03   ` Jan Kratochvil
2008-11-01 18:54     ` Joel Brobecker
2008-11-11 20:20       ` Jan Kratochvil
2008-11-13 14:27         ` Joel Brobecker [this message]
2008-11-21  1:11           ` Jan Kratochvil
2008-11-22 18:35             ` Joel Brobecker
2008-11-22 19:08             ` Eli Zaretskii
2008-11-24  2:25               ` Joel Brobecker
2008-11-24  7:09                 ` Jan Kratochvil
2008-11-25 17:49                   ` Joel Brobecker
2008-11-27  0:41                     ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081113053100.GL5112@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox