From: Simon Marchi <simark@simark.ca>
To: Weimin Pan <weimin.pan@oracle.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] gdb: CTF support
Date: Wed, 02 Oct 2019 02:47:00 -0000 [thread overview]
Message-ID: <0fe82814-46b8-79c2-6a25-5f5d51b158e1@simark.ca> (raw)
In-Reply-To: <895f47d4-3e01-4d5a-474b-43dd2dd037b4@oracle.com>
On 2019-09-30 8:36 p.m., Weimin Pan wrote:
> Thank you very much for the thorough review. I have read through the
> modified patch which looks good and will be adopted. In addition, I
> have made more changes to address the issues you raised. Please see
> below and the updated patch (attached).
Great thanks!
I noticed at least one case of leading spaces that should be tab in the attached
patch, so maybe do:
grep '^ ' ctfread.c
to catch them.
> Yes, I've made the change in several places where the allocated copy is
> freed after
> it's being dup'ed via obstack_strdup.
Ok thanks. Actually, can you please use gdb::unique_xmalloc_pointer to
manage that memory? We're trying to minimize the manual memory management
in GDB. You'd do:
gdb::unique_xmalloc_ptr<char> name (ctf_type_aname_raw (fp, tid));
and use `name.get ()` instead of name. It will get free'd automatically
when exiting scope.
> Actually callers of these read_foo functions will call the appropriate
> function, based
> on the tid's kind. For example, either ctf_add_type_cb or
> process_structure_type
> calls read_structure_type only if tid's kind is CTF_K_STRUCT or
> CTF_K_STRUCT.
Ok, I was hoping it would make the code more robust in case someone does
some refactor in the future and one of these functions get called with an
object of the wrong type, but maybe it would be overkill.
> > Hmm that looks fishy. It looks like this is taking the address of a
> > local variable for something that will be used after the current function
> > will have returned.
>
> Sorry, but it's a "static" local variable.
Oh ok, I did miss that.
I think we should avoid this. What happens, for example, in this case:
1. Read psymtab for objfile 1
2. Read psymtab for objfile 2
3. Expand psymtab to symtab for objfile 1
From what I understand, step #2 will overwrite the static variable, such that
it won't be valid anymore in step #3. I think it would be better to allocate the
context structure dynamically and store it as the objfile, like dwarf2read does.
Thanks,
Simon
next prev parent reply other threads:[~2019-10-02 2:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-30 23:45 Weimin Pan
2019-09-21 22:21 ` Simon Marchi
2019-09-23 21:11 ` Weimin Pan
2019-09-24 3:10 ` Simon Marchi
2019-09-25 0:22 ` Weimin Pan
2019-09-25 0:27 ` Simon Marchi
2019-09-25 2:04 ` Wei-min Pan
2019-09-25 2:35 ` Simon Marchi
2019-09-25 21:09 ` Wei-min Pan
2019-09-30 3:06 ` Simon Marchi
2019-10-01 0:37 ` Weimin Pan
2019-10-02 2:47 ` Simon Marchi [this message]
2019-10-02 23:10 ` Wei-min Pan
2019-10-03 12:40 ` Simon Marchi
2019-10-03 17:59 ` Wei-min Pan
2019-10-03 18:01 ` Simon Marchi
2019-10-03 18:21 ` Wei-min Pan
2019-10-03 18:31 ` Simon Marchi
2019-10-03 18:53 ` Wei-min Pan
2019-10-03 20:33 ` 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=0fe82814-46b8-79c2-6a25-5f5d51b158e1@simark.ca \
--to=simark@simark.ca \
--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