Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Weimin Pan <weimin.pan@oracle.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v5] gdb: ADI support
Date: Thu, 27 Jul 2017 15:49:00 -0000	[thread overview]
Message-ID: <868tj9riar.fsf@gmail.com> (raw)
In-Reply-To: <1501115399-33066-1-git-send-email-weimin.pan@oracle.com> (Weimin	Pan's message of "Wed, 26 Jul 2017 19:29:59 -0500")

Weimin Pan <weimin.pan@oracle.com> writes:

> +
> +/* ADI stat settings.  */
> +typedef struct
> +{
> +  /* The ADI block size.  */
> +  unsigned long blksize;
> +
> +  /* Number of bits used for an ADI version tag which can be
> +   * used together with the shift value for an ADI version tag
> +   * to encode or extract the ADI version value in a pointer.  */
> +  unsigned long nbits;
> +
> +  /* The maximum ADI version tag value supported.  */
> +  int max_version;
> +
> +  /* ADI version tag file.  */
> +  int tag_fd;
> +
> +  /* ADI availability check has been done.  */
> +  bool checked_avail;
> +
> +  /* ADI is available.  */
> +  bool is_avail;
> +
> +} adi_stat_t;
> +
> +/* Per-process ADI stat info.  */
> +
> +typedef struct 
> +{
> +  /* The process identifier.  */
> +  pid_t pid;
> +
> +  /* The ADI stat.  */
> +  adi_stat_t stat;
> +} sparc64_adi_info;
> +
> +static std::forward_list<sparc64_adi_info *> a_proc_list;

a_proc_list is not a good variable name.  How about adi_proc_list?

Can you use "std::forward_list<sparc64_adi_info>" instead?  I am reading
book "C++ Coding Standards: 101 Rules, Guidelines, and Best Practices",
and know rule 79 is "Store only values and smart pointers in
containers".  I know we have "std::forward_list<regcache *>", and I am
trying to fix it.

> +
> +/* Find ADI info for process PID.  */
> +
> +static sparc64_adi_info *
> +find_adi_info (pid_t pid)
> +{
> +  sparc64_adi_info *proc;
> +
> +  for ( auto it = a_proc_list.begin(); it != a_proc_list.end(); ++it
> )

for (const auto &info : a_proc_list)

> +    if ((*it)->pid == pid)
> +      return (*it);
> +
> +  return NULL;
> +}
> +
> +/* Add ADI info for process PID.  Returns newly allocated info
> +   object.  */
> +
> +static sparc64_adi_info *
> +add_adi_info (pid_t pid)
> +{
> +  sparc64_adi_info *proc = XCNEW (sparc64_adi_info);
> +
> +  proc->pid = pid;
> +  proc->stat.is_avail = false;
> +  proc->stat.checked_avail = false;
> +  proc->stat.tag_fd = 0;
> +  a_proc_list.push_front (proc);
> +
> +  return proc;
> +}
> +
> +/* Get ADI info for process PID, creating one if it doesn't exist.  */
> +
> +static sparc64_adi_info * 
> +get_adi_info_proc (pid_t pid)
> +{
> +  sparc64_adi_info *proc;
> +
> +  proc = find_adi_info (pid);
> +  if (proc == NULL)
> +    proc = add_adi_info (pid);
> +
> +  return proc;
> +}
> +
> +static adi_stat_t 
> +get_adi_info (pid_t pid)
> +{
> +  sparc64_adi_info *proc;
> +
> +  proc = get_adi_info_proc (pid);
> +  return proc->stat;
> +}
> +
> +/* Is called when GDB is no longer debugging process PID.  It
> +   deletes data structure that keeps track of the ADI stat.  */
> +
> +void
> +sparc64_forget_process (pid_t pid)
> +{
> +  sparc64_adi_info *proc;
> +  int target_errno;
> +
> +  proc = find_adi_info (pid);
> +  if (proc != NULL)
> +    { 
> +      if (proc->stat.tag_fd > 0) 
> +        target_fileio_close (proc->stat.tag_fd, &target_errno);
> +      a_proc_list.remove (proc);
> +      xfree (proc);
> +    }
> +
> +}
> +

> +
> +int main ()
> +{
> +  char *haddr;
> +  caddr_t vaddr;
> +  int	version;
> +
> +  // test ISM

We have mixed comment styles, // and "/**/".  Since it is a c code, we
can use /**/?

> +  int shmid = shmget (IPC_PRIVATE, SHMSIZE, IPC_CREAT | 0666);
> +  if (shmid == -1) 
> +    exit(1);
> +  char *shmaddr = (char *)shmat (shmid, NULL, 0x666 | SHM_RND);
> +  if (shmaddr == (char *)-1) 
> +    { 
> +      shmctl (shmid, IPC_RMID, NULL); 
> +      exit(1);
> +    }
> +  // enable ADI on ISM segment

It is a sentence, so Capitalize 'E', and put "." at the end.

/* Enable ADI on ISM segment.  */

-- 
Yao (齐尧)


  reply	other threads:[~2017-07-27 15:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-27  0:38 Weimin Pan
2017-07-27 15:49 ` Yao Qi [this message]
2017-07-27 16:44   ` Wei-min Pan
2017-07-27 17:04 ` Eli Zaretskii
2017-07-27 17:12   ` Wei-min Pan

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=868tj9riar.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=weimin.pan@oracle.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