<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Yup, I use that as well. I guess we can print both the pointer and
the stable identifier alongside each other. Or we could add a flag
to choose between those, but that's less comfy.<br>
<br>
<div class="moz-cite-prefix">On 8/29/18 11:54 AM, David Blaikie
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAENS6EvRXsijcXjmg4X0c-6ZOfqTXnrSd+EBVB7K5jNqTweOug@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">Mostly what Richard said.<br>
<br>
One thing I'd be a bit careful of - these numbers may still not
be stable in some small number of cases (eg: if objects are
created based on iteration order of a pointer-based hashing
container - which may still be valid if that ordering doesn't
leak into the output of the program). So this might provide a
slightly false sense of security & make those minority cases
more painful - but perhaps they're rare enough that it's worth
the tradeoff.<br>
<br>
(& as Richard said - debuggers will tend to disable ASLR
anyway, making it relatively easy to work with)</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Tue, Aug 28, 2018 at 6:16 PM Richard Smith via
cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org"
moz-do-not-send="true">cfe-dev@lists.llvm.org</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div dir="auto">
<div>
<div class="gmail_quote">
<div dir="ltr">On Tue, 28 Aug 2018, 17:14 Artem
Dergachev via cfe-dev, <<a
href="mailto:cfe-dev@lists.llvm.org"
target="_blank" moz-do-not-send="true">cfe-dev@lists.llvm.org</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">In
various debug dumps (eg., Clang's -ast-dump),
various objects (eg., <br>
Stmts and Decls in that -ast-dump) are identified by
pointers. It's very <br>
reliable in the sense that no two objects would ever
have the same <br>
pointer at the same time, but it's unpleasant that
pointers change <br>
across runs. Having deterministic identifiers
instead of pointers would <br>
aid debugging: imagine a conditional break by object
identifier that has <br>
not yet been constructed, or simply trying to align
two debug dumps of <br>
different kind from different runs together.
Additionally, pointers are <br>
hard to read and memorize; it's hard to notice the
difference between <br>
0x7f80a28325e0 and 0x7f80a28325a0, especially when
they're a few screens <br>
apart.<br>
<br>
Hence the idea: why don't we print the offset into
the allocator's <br>
memory slab instead of a pointer?</blockquote>
</div>
</div>
<div dir="auto"><br>
</div>
</div>
</div>
<div dir="ltr">
<div dir="auto">
<div dir="auto">Make this "as well as" rather than
"instead of" and it sounds great to me. When debugging,
it's useful to be able to dump a large complex object,
find the piece you want, grab its address and start
accessing it directly.</div>
<div dir="auto"><br>
</div>
<div>(For the pointer stability problem, at least on Linux
you can turn off ASLR. When running under gdb, that's
typically done for you, and you can do it manually with
setarch. But it would be nice to have an easier way to
identify objects than a long, essentially meaningless
address.)</div>
</div>
</div>
<div dir="ltr">
<div dir="auto">
<div dir="auto"><br>
</div>
<div dir="auto">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">We
use BumpPtrAllocator all over the <br>
place, which boils down to a set of slabs on which
all objects are <br>
placed in the order in which they are allocated. It
is easy for the <br>
allocator to identify if a pointer belongs to that
allocator, and if so, <br>
deteremine which slab it belongs to and at what
offset the object is in <br>
that slab. Therefore it is possible to identify the
object by its (slab <br>
index, offset) pair. Eg., "TypedefDecl 0:528" (you
already memorized it) <br>
instead of "TypedefDecl 0x7f80a28325e0". This could
be applied to all <br>
sorts of objects that live in BumpPtrAllocators.<br>
<br>
In order to compute such identifier, we only need
access to the object <br>
and to the allocator. No additional memory is used
to store such <br>
identifier. Such identifier would also be persistent
across runs as long <br>
as the same objects are allocated in the same order,
which is, i <br>
suspect, often the case.<br>
<br>
One of the downsides of this identifier is that it's
not going to be the <br>
same on different machines, because the same data
structure may require <br>
different amounts of memory on different hosts. So
it wouldn't <br>
necessarily help understanding a dump that the user
sent you. But it <br>
still seems to be better than pointers.<br>
<br>
Should we go ahead and try to implement it?<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org"
rel="noreferrer" target="_blank"
moz-do-not-send="true">cfe-dev@lists.llvm.org</a><br>
<a
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev"
rel="noreferrer noreferrer" target="_blank"
moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
</div>
</div>
</div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank"
moz-do-not-send="true">cfe-dev@lists.llvm.org</a><br>
<a
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev"
rel="noreferrer" target="_blank" moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
</blockquote>
<br>
</body>
</html>