OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import cStringIO | 6 import cStringIO |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 import textwrap | 10 import textwrap |
11 import unittest | 11 import unittest |
12 | 12 |
13 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 13 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
14 sys.path.insert(0, ROOT_DIR) | 14 sys.path.insert(0, ROOT_DIR) |
15 | 15 |
16 import reduce_debugline | 16 import reduce_debugline |
17 | 17 |
18 | 18 |
19 class ReduceDebuglineTest(unittest.TestCase): | 19 class ReduceDebuglineTest(unittest.TestCase): |
20 _DECODED_DEBUGLINE = textwrap.dedent("""\ | 20 _DECODED_DEBUGLINE = textwrap.dedent("""\ |
21 Decoded dump of debug contents of section .debug_line: | 21 Decoded dump of debug contents of section .debug_line: |
22 | 22 |
23 CU: ../../chrome/app/chrome_exe_main_gtk.cc: | 23 CU: ../../chrome/service/service_main.cc: |
24 File name Line number Starting address | 24 File name Line number Starting address |
25 chrome_exe_main_gtk.cc 33 0xa3be50 | 25 service_main.cc 21 0xa41210 |
26 | 26 |
27 chrome_exe_main_gtk.cc 34 0xa3be66 | 27 service_main.cc 24 0xa4141f |
28 chrome_exe_main_gtk.cc 39 0xa3be75 | 28 service_main.cc 30 0xa4142b |
29 chrome_exe_main_gtk.cc 42 0xa3be7a | 29 service_main.cc 31 0xa4143e |
30 | 30 |
31 CU: ../../chrome/app/chrome_main.cc: | 31 ../../base/message_loop.h: |
32 File name Line number Starting address | 32 message_loop.h 550 0xa41300 |
33 chrome_main.cc 30 0xa3be90 | |
34 | 33 |
35 chrome_main.cc 31 0xa3bea3 | 34 message_loop.h 551 0xa41310 |
36 chrome_main.cc 32 0xa3beaf | |
37 chrome_main.cc 34 0xa3bec9 | |
38 chrome_main.cc 32 0xa3bed1 | |
39 | 35 |
40 CU: ../../chrome/app/chrome_main_delegate.cc: | 36 ../../base/logging.h: |
41 File name Line number Starting address | 37 logging.h 246 0xa41710 |
42 chrome_main_delegate.cc 320 0xa3bee0 | |
43 | 38 |
44 chrome_main_delegate.cc 320 0xa3bef0 | 39 logging.h 247 0xa41726 |
45 chrome_main_delegate.cc 321 0xa3bf43 | |
46 chrome_main_delegate.cc 322 0xa3bf48 | |
47 chrome_main_delegate.cc 324 0xa3bf50 | |
48 chrome_main_delegate.cc 324 0xa3bf60 | |
49 | 40 |
50 chrome_main_delegate.cc 612 0xa3cd54 | 41 ../../base/logging.h: |
51 chrome_main_delegate.cc 617 0xa3cd6b | 42 logging.h 846 0xa3fd90 |
52 chrome_main_delegate.cc 299 0xa3d5fd | |
53 chrome_main_delegate.cc 300 0xa3d605 | |
54 | 43 |
55 ../../content/public/app/content_main_delegate.h: | 44 logging.h 846 0xa3fda0 |
56 content_main_delegate.h 22 0xa3d620 | |
57 | |
58 content_main_delegate.h 22 0xa3d637 | |
59 | |
60 ../../chrome/common/chrome_content_client.h: | |
61 chrome_content_client.h 16 0xa3d640 | |
62 | |
63 chrome_content_client.h 16 0xa3d650 | |
64 | |
65 ../../base/memory/scoped_ptr.h: | |
66 scoped_ptr.h 323 0xa3d680 | |
67 | |
68 scoped_ptr.h 323 0xa3d690 | |
69 | |
70 ../../base/memory/scoped_ptr.h: | |
71 scoped_ptr.h 323 0xa3d660 | |
72 | |
73 scoped_ptr.h 323 0xa3d670 | |
74 | |
75 ../../base/memory/scoped_ptr.h: | |
76 scoped_ptr.h 428 0xa3d6a0 | |
77 | |
78 scoped_ptr.h 428 0xa3d6b0 | |
79 | |
80 CU: ../../something.c: | |
81 File name Line number Starting address | |
82 something.c 57 0x76e2cc0 | |
83 | |
84 something.c 62 0x76e2cd3 | |
85 something.c 64 0x76e2cda | |
86 something.c 65 0x76e2ce9 | |
87 something.c 66 0x76e2cf8 | |
88 | 45 |
89 """) | 46 """) |
90 | 47 |
91 _EXPECTED_REDUCED_DEBUGLINE = { | 48 _EXPECTED_REDUCED_DEBUGLINE = [ |
92 '../../chrome/app/chrome_exe_main_gtk.cc': [ | 49 (0xa3fd90, '../../base/logging.h'), |
93 (0xa3be50, 0xa3be50), | 50 (0xa41210, '../../chrome/service/service_main.cc'), |
94 (0xa3be66, 0xa3be7a), | 51 (0xa41300, '../../base/message_loop.h'), |
95 ], | 52 (0xa4141f, '../../chrome/service/service_main.cc'), |
96 '../../chrome/app/chrome_main.cc': [ | 53 (0xa41710, '../../base/logging.h'), |
97 (0xa3be90, 0xa3be90), | 54 ] |
98 (0xa3bea3, 0xa3bed1), | |
99 ], | |
100 '../../chrome/app/chrome_main_delegate.cc': [ | |
101 (0xa3bee0, 0xa3bee0), | |
102 (0xa3bef0, 0xa3bf60), | |
103 (0xa3cd54, 0xa3d605), | |
104 ], | |
105 '../../content/public/app/content_main_delegate.h': [ | |
106 (0xa3d620, 0xa3d620), | |
107 (0xa3d637, 0xa3d637), | |
108 ], | |
109 '../../chrome/common/chrome_content_client.h': [ | |
110 (0xa3d640, 0xa3d640), | |
111 (0xa3d650, 0xa3d650), | |
112 ], | |
113 '../../base/memory/scoped_ptr.h': [ | |
114 (0xa3d680, 0xa3d680), | |
115 (0xa3d690, 0xa3d690), | |
116 (0xa3d660, 0xa3d660), | |
117 (0xa3d670, 0xa3d670), | |
118 (0xa3d6a0, 0xa3d6a0), | |
119 (0xa3d6b0, 0xa3d6b0), | |
120 ], | |
121 '../../something.c': [ | |
122 (0x76e2cc0, 0x76e2cc0), | |
123 (0x76e2cd3, 0x76e2cf8), | |
124 ], | |
125 } | |
126 | 55 |
127 def test(self): | 56 def test(self): |
128 ranges_dict = reduce_debugline.reduce_decoded_debugline( | 57 ranges_dict = reduce_debugline.reduce_decoded_debugline( |
129 cStringIO.StringIO(self._DECODED_DEBUGLINE)) | 58 cStringIO.StringIO(self._DECODED_DEBUGLINE)) |
130 self.assertEqual(self._EXPECTED_REDUCED_DEBUGLINE, ranges_dict) | 59 self.assertEqual(self._EXPECTED_REDUCED_DEBUGLINE, ranges_dict) |
131 | 60 |
132 | 61 |
133 if __name__ == '__main__': | 62 if __name__ == '__main__': |
134 logging.basicConfig( | 63 logging.basicConfig( |
135 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR, | 64 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR, |
136 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 65 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
137 unittest.main() | 66 unittest.main() |
OLD | NEW |