[Lldb-commits] [lldb] r325927 - Replace HashStringUsingDJB with llvm::djbHash

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 8 02:49:28 PST 2018

On Thu, 8 Mar 2018 at 02:46, Davide Italiano <dccitaliano at gmail.com> wrote:

> On Wed, Mar 7, 2018 at 6:39 PM, Jim Ingham <jingham at apple.com> wrote:
> > The hashing algorithm gives different values - at least for foobár -
> between the two implementations.  So if you build with an older clang, and
> test with a new lldb, the type lookup fails.
> >
When I landed this patch, the two algorithms were identical, but this
wasn't always the case. The llvm's version of the algorithm used to be
nondeterministic (as in, it's result depended on the signedness of char on
your platform). This was recently fixed, and this patch was meant to make
sure they always stay in sync.

We considered a couple of options when we noticed this discrepancy, but
since this had never really worked (llvm and lldb had always disagreed on
the hash value of strings with high bit set) and nobody noticed, we decided
to just fix the llvm implementation. The other option was to create a
signedDJBHash function, and make lldb&llvm always use that for apple
accelerator tables. I guess it's still not too late to do that....

> This is not my case, I think? I'm building from the monorepo so clang
> and lldb are supposed to be in sync (in fact, the version of clang in
> my test is 7.0).
My best (and only) guess would be that this is because of different
versions of dsymutil (we are using the system dsymutil to build the dsym
bundle), though I'm not sure then why the test doesn't fail for me as well,
as I have the stock dsymutil that ships which XCode, which presumably still
has the broken hash function.

Could you send me the main.o and a.out.dSYM files that are built by this
test (or at least the output of running llvm-dwarfdump -apple-types on
them), so I can compare them with mine? The interesting question is what
does "foobár" hash to (for me it's 0xba721fe1 in both files).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180308/0be2771a/attachment.html>

More information about the lldb-commits mailing list