Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Issue 5340003: Make a new test to enforce the sizes of all structs and enums in the C API.... (Closed)

Created:
10 years ago by dmichael(do not use this one)
Modified:
9 years, 7 months ago
Reviewers:
sehr, brettw, neb
CC:
chromium-reviews
Visibility:
Public.

Description

Make a new test to enforce the sizes of all structs and enums in the C API. Originally, I was going to just run through and add the asserts manually after each definition, but I decided to experiment with Clang and try to automate it. The Clang plugin I wrote and ran is here: /home/dmichael/www/clang_plugins/PrintNamesAndSizes.cpp I used that and some simple search/replace to make test_c_sizes.c. The idea is that the sizes need to be consistent across platforms & compilers. Also, if the size is consistent should (in all practical cases) imply that the alignment is also the same. It's possible that if we added other architectures where e.g. floats are a different size, we'd need to make a 'test_c_sizes' for each platform family... but for now, I think all our platforms have the same size for all the structs (which is nice). I would love to add this tool somewhere, but I have no idea where (if anywhere) would make sense to put it. If it was checked-in, we could run it periodically or as part of a gyp action to make sure we know if we change the size of something in the C ABI. BUG=61004, 92983 TEST=test_c_sizes.c Closing uncommitted; I broke this up in to these 2: http://codereview.chromium.org/5730003 http://codereview.chromium.org/5730004

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 4

Patch Set 3 : '' #

Patch Set 4 : '' #

Patch Set 5 : '' #

Patch Set 6 : '' #

Patch Set 7 : '' #

Patch Set 8 : '' #

Patch Set 9 : '' #

Patch Set 10 : '' #

Patch Set 11 : '' #

Patch Set 12 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+839 lines, -199 lines) Patch
M ppapi/c/dev/pp_cursor_type_dev.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +3 lines, -0 lines 0 comments Download
M ppapi/c/dev/pp_file_info_dev.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +4 lines, -0 lines 0 comments Download
M ppapi/c/dev/pp_video_dev.h View 1 2 3 4 5 6 7 8 9 10 11 12 chunks +42 lines, -7 lines 0 comments Download
M ppapi/c/dev/ppb_audio_config_dev.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M ppapi/c/dev/ppb_char_set_dev.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M ppapi/c/dev/ppb_directory_reader_dev.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +8 lines, -0 lines 0 comments Download
M ppapi/c/dev/ppb_file_chooser_dev.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M ppapi/c/dev/ppb_file_io_dev.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M ppapi/c/dev/ppb_font_dev.h View 1 2 3 4 5 6 7 8 9 10 11 6 chunks +16 lines, -3 lines 0 comments Download
M ppapi/c/dev/ppb_opengles_dev.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +14 lines, -0 lines 0 comments Download
M ppapi/c/dev/ppb_scrollbar_dev.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M ppapi/c/dev/ppb_url_util_dev.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -0 lines 0 comments Download
M ppapi/c/dev/ppp_printing_dev.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +4 lines, -0 lines 0 comments Download
M ppapi/c/pp_bool.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +0 lines, -1 line 0 comments Download
M ppapi/c/pp_input_event.h View 1 2 3 4 5 6 7 8 9 10 11 7 chunks +7 lines, -0 lines 0 comments Download
M ppapi/c/pp_instance.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -0 lines 0 comments Download
M ppapi/c/pp_macros.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +34 lines, -1 line 0 comments Download
M ppapi/c/pp_module.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -0 lines 0 comments Download
M ppapi/c/pp_point.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M ppapi/c/pp_rect.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M ppapi/c/pp_resource.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -0 lines 0 comments Download
M ppapi/c/pp_size.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M ppapi/c/pp_time.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +4 lines, -0 lines 0 comments Download
M ppapi/c/pp_var.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +13 lines, -6 lines 0 comments Download
M ppapi/c/ppb_image_data.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -0 lines 0 comments Download
M ppapi/c/ppb_url_request_info.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -0 lines 0 comments Download
M ppapi/c/ppb_url_response_info.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -0 lines 0 comments Download
M ppapi/c/ppb_var.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +10 lines, -0 lines 0 comments Download
M ppapi/generate_ppapi_include_tests.py View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +18 lines, -11 lines 0 comments Download
A ppapi/generate_ppapi_size_checks.py View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +334 lines, -0 lines 0 comments Download
M ppapi/ppapi.gyp View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +6 lines, -2 lines 0 comments Download
A + ppapi/tests/all_c_includes.h View 1 2 3 4 5 6 7 3 chunks +4 lines, -1 line 0 comments Download
A ppapi/tests/all_c_sizes.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +42 lines, -0 lines 0 comments Download
A ppapi/tests/all_cpp_includes.h View 1 2 3 4 5 6 7 1 chunk +56 lines, -0 lines 0 comments Download
A ppapi/tests/all_sizes_32.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +79 lines, -0 lines 0 comments Download
A ppapi/tests/all_sizes_64.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +79 lines, -0 lines 0 comments Download
D ppapi/tests/test_c_includes.c View 1 2 3 4 5 6 7 8 9 1 chunk +4 lines, -69 lines 0 comments Download
M ppapi/tests/test_cc_includes.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +0 lines, -53 lines 0 comments Download
A + ppapi/tests/test_cpp_includes.cc View 1 2 3 4 5 6 7 2 chunks +2 lines, -45 lines 0 comments Download
A ppapi/tests/test_struct_sizes_c.c View 1 2 3 4 5 6 7 1 chunk +17 lines, -0 lines 0 comments Download
A ppapi/tests/test_struct_sizes_cpp.cc View 1 2 3 4 5 6 7 1 chunk +16 lines, -0 lines 0 comments Download

Messages

Total messages: 15 (0 generated)
dmichael(do not use this one)
This may be an insane or brilliant approach; I'm not sure which. I understand it ...
10 years ago (2010-11-24 20:18:03 UTC) #1
brettw
I guess this is OK. It's nice that it doesn't miss anything, but it sucks ...
10 years ago (2010-11-24 22:36:40 UTC) #2
dmichael(do not use this one)
I saw a lot of failures on the Windows & Mac trybots due to the ...
10 years ago (2010-11-24 23:23:15 UTC) #3
neb at google
It's strange to me that function pointers are different sizes. That can be true for ...
10 years ago (2010-11-25 02:39:24 UTC) #4
dmichael(do not use this one)
On 2010/11/25 02:39:24, neb at google wrote: > It's strange to me that function pointers ...
10 years ago (2010-11-29 21:04:53 UTC) #5
dmichael(do not use this one)
Okay, I've got clean try runs now, and I also made the size checks work ...
10 years ago (2010-11-30 20:20:27 UTC) #6
brettw
On Tue, Nov 30, 2010 at 12:20 PM, <dmichael@google.com> wrote: > Okay, I've got clean ...
10 years ago (2010-11-30 20:45:44 UTC) #7
neb
I don't recall that we have pointers in structs on any performance-critical places - can ...
10 years ago (2010-12-08 23:44:46 UTC) #8
dmichael(do not use this one)
On Wed, Dec 8, 2010 at 4:44 PM, <neb@chromium.org> wrote: > I don't recall that ...
10 years ago (2010-12-09 00:34:59 UTC) #9
neb
> I could see doing this for data structs, but it would seem weird to ...
10 years ago (2010-12-09 18:58:39 UTC) #10
brettw
On Wed, Dec 8, 2010 at 3:57 PM, David Michael <dmichael@google.com> wrote: > > > ...
10 years ago (2010-12-09 19:03:11 UTC) #11
dmichael(do not use this one)
Sorry for the late response, we had a 3 hour meeting turn in to a ...
10 years ago (2010-12-09 23:09:20 UTC) #12
brettw
On Thu, Dec 9, 2010 at 3:09 PM, David Michael <dmichael@google.com> wrote: > Sorry for ...
10 years ago (2010-12-09 23:47:43 UTC) #13
neb
> I'm interested in Neb's opinion. It seems to me like adding or > removing ...
10 years ago (2010-12-10 00:04:49 UTC) #14
dmichael(do not use this one)
10 years ago (2010-12-10 16:36:36 UTC) #15
>
>
> I don't see that checking the size of the structs amounts to version
> checking.
> Changing the signature of a function, for example, is not detected.

You're right, it would only catch a subset of changes.

It's a nice
> check to have for most other structures though, because there it does catch
> non-obvious signature changes. So +1 for not doing to much work there.

It's easy on my end (with the automation I already have).  But I think I'm
hearing that it won't be helpful enough for the amount of trouble it causes
PPAPI developers.  I'll leave it out.

And no
> padding, that was just silly to suggest of me.
>
>
> http://codereview.chromium.org/5340003/
>

This CL got a little out of control, so I'm going to break it up and upload
probably 2:
-1 for adding the actual checks and massaging a few structs to be consistent
size.
-1 for adding the tools to update it automatically later. (Clang plugins +
python)

Powered by Google App Engine
This is Rietveld 408576698