This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizer][MIPS] internal_stat for mips64
ClosedPublic

Authored by mohit.bhakkad on Nov 24 2014, 6:55 AM.

Details

Summary

For mips64, structure of the buffer after stat syscall is of kernel_stat, and we need to convert it to stat form.

Diff Detail

Event Timeline

mohit.bhakkad retitled this revision from to [Sanitizer][MIPS] internal_stat for mips64.
mohit.bhakkad updated this object.
mohit.bhakkad edited the test plan for this revision. (Show Details)
mohit.bhakkad added reviewers: petarj, kcc, samsonov.
mohit.bhakkad set the repository for this revision to rL LLVM.
mohit.bhakkad added subscribers: Unknown Object (MLST), sdkie, slthakur, dsanders.
kcc edited edge metadata.Nov 24 2014, 3:34 PM

interestingly, I don't see any uses of internal_lstat.
Does anyone know if we still need it?
Maybe we just delete it?

We call internal_lstat() from internal symbolizer. I don't know if calling regular interceptor would work there (adding Dmitry).

mohit.bhakkad planned changes to this revision.Nov 25 2014, 1:00 AM
mohit.bhakkad edited edge metadata.
mohit.bhakkad set the repository for this revision to rL LLVM.
samsonov added inline comments.Nov 25 2014, 4:20 PM
lib/sanitizer_common/sanitizer_linux.cc
192

Use

#if defined(__mips64)
219

Nest compiler directives like this:

#if FOO
# if BAR
   // code
 # endif
#endif
lib/sanitizer_common/sanitizer_platform.h
121 ↗(On Diff #16600)

Is there no header you can #include in sanitizer_linux.cc on MIPS to get the definition of this structure?

In any case, this is the wrong place for the declaration. If you absolutely must provide the declaration, move it to sanitizer_platform_limits_posix.h

mohit.bhakkad set the repository for this revision to rL LLVM.

Changes in this revision:

  • Including asm/stat.h to get definition of kernel_stat
samsonov added inline comments.Nov 28 2014, 8:16 PM
lib/sanitizer_common/sanitizer_linux.cc
51

Please turn this comment into a few regular english sentences with proper punctuation. It's hard to understand it otherwise.

mohit.bhakkad added inline comments.Dec 1 2014, 2:02 AM
lib/sanitizer_common/sanitizer_linux.cc
51

Hi @samsonov, is it OK to write it like:

/* For mips64, syscall(__NR_stat) fills the buffer in the 'struct kernel_stat' format. 
   Struct kernel_stat is defined as 'struct stat' in asm/stat.h. To access stat from 
   asm/stat.h, without conflicting with definition in sys/stat.h, we use this trick. */
samsonov accepted this revision.Dec 1 2014, 12:48 PM
samsonov edited edge metadata.

LGTM

lib/sanitizer_common/sanitizer_linux.cc
51

Alright, I see what you mean now :) (but use //-style comments)

This revision is now accepted and ready to land.Dec 1 2014, 12:48 PM
mohit.bhakkad edited edge metadata.
mohit.bhakkad set the repository for this revision to rL LLVM.

Changes in this revision:

  • Updated the comment/explanation as suggested
In D6385#23, @samsonov wrote:

LGTM

Thanks @samsonov
I don't have commit access, can you please commit it for me?

I haven't been following the sanitizer reviews particularly closely but from what I've seen yourself and Kumar have been cooperating with the review process properly. If the others agree, perhaps it's time to request commit access.

kcc added a comment.Dec 5 2014, 2:23 PM

If the others agree, perhaps it's time to request commit access.

Yes, I'd support granting post-review commit rights to Mohit.