From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3512 invoked by alias); 27 Jul 2017 15:49:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 3493 invoked by uid 89); 27 Jul 2017 15:49:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Practices, capitalize, Standards, Coding X-HELO: mail-io0-f196.google.com Received: from mail-io0-f196.google.com (HELO mail-io0-f196.google.com) (209.85.223.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Jul 2017 15:49:57 +0000 Received: by mail-io0-f196.google.com with SMTP id j32so7790127iod.3 for ; Thu, 27 Jul 2017 08:49:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=05WlQwlhsasVv8dsaOpETOcr/a8LLzp4ZzTZLwcj/KA=; b=LEM4HI6yKwcomDXlNSqqijqIEvMlK0dgENBy33wJRlnXKEA4FNe4Fy3Ky5OwY7DVHp FAh04Y9pZZ4xhR/9pqeY/gVAFjDDJLigAL1B1Wn9CAdoXvGhNv5LehG5le4CLfv9dcgH ipXWK5tAJBIAfZuVJ92FYonha8+e2fA/nDsDBpji+3Hbl4ssUPSyoJqn73FAG849VqFY GFqIWfq3BeAlNTnMWZgrnGDiSVZI+7j6cNhgLAG+ZdxhwfXFnVVDtfI4Z1R3wJSfToiE Sdk/4WsjkddczIQ1pgspO1W3zFwIDUai9UM/nnDfSNXvpRWcqoGuylOl+KkJ+GT196sk xEmw== X-Gm-Message-State: AIVw110sMnkjA/q2BoRAqn2Odd6Gi2EHed9nWzxlZvUBJ4Nv59CHn0x5 67zYSlhqRVEycOxg X-Received: by 10.107.34.18 with SMTP id i18mr5264979ioi.185.1501170595994; Thu, 27 Jul 2017 08:49:55 -0700 (PDT) Received: from E107787-LIN (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id a127sm7411082itd.33.2017.07.27.08.49.54 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 27 Jul 2017 08:49:55 -0700 (PDT) From: Yao Qi To: Weimin Pan Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v5] gdb: ADI support References: <1501115399-33066-1-git-send-email-weimin.pan@oracle.com> Date: Thu, 27 Jul 2017 15:49:00 -0000 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") Message-ID: <868tj9riar.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg00424.txt.bz2 Weimin Pan 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=20 > +{ > + /* The process identifier. */ > + pid_t pid; > + > + /* The ADI stat. */ > + adi_stat_t stat; > +} sparc64_adi_info; > + > +static std::forward_list a_proc_list; a_proc_list is not a good variable name. How about adi_proc_list? Can you use "std::forward_list" 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", 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 =3D a_proc_list.begin(); it !=3D a_proc_list.end(); ++it > ) for (const auto &info : a_proc_list) > + if ((*it)->pid =3D=3D 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 =3D XCNEW (sparc64_adi_info); > + > + proc->pid =3D pid; > + proc->stat.is_avail =3D false; > + proc->stat.checked_avail =3D false; > + proc->stat.tag_fd =3D 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 *=20 > +get_adi_info_proc (pid_t pid) > +{ > + sparc64_adi_info *proc; > + > + proc =3D find_adi_info (pid); > + if (proc =3D=3D NULL) > + proc =3D add_adi_info (pid); > + > + return proc; > +} > + > +static adi_stat_t=20 > +get_adi_info (pid_t pid) > +{ > + sparc64_adi_info *proc; > + > + proc =3D 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 =3D find_adi_info (pid); > + if (proc !=3D NULL) > + {=20 > + if (proc->stat.tag_fd > 0)=20 > + 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 =3D shmget (IPC_PRIVATE, SHMSIZE, IPC_CREAT | 0666); > + if (shmid =3D=3D -1)=20 > + exit(1); > + char *shmaddr =3D (char *)shmat (shmid, NULL, 0x666 | SHM_RND); > + if (shmaddr =3D=3D (char *)-1)=20 > + {=20 > + shmctl (shmid, IPC_RMID, NULL);=20 > + exit(1); > + } > + // enable ADI on ISM segment It is a sentence, so Capitalize 'E', and put "." at the end. /* Enable ADI on ISM segment. */ --=20 Yao (=E9=BD=90=E5=B0=A7)