1 /*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <unistd.h>
18 #include <stdio.h>
19 #include <malloc.h>
20 #include <string.h>
21
22 /* Currently debuggerd dumps 20 words each around PC and LR */
23 #define NUM_DUMPED_WORDS 20
24
25 volatile int done;
26
27 /*
28 * See README.txt for detailed steps.
29 *
30 * If you see a native crash in the bugreport and the PC/LR are
31 * pointing to the code cache address range, copy them into the following
32 * arrays.
33 *
34 * #00 pc 463ba204
35 * #01 lr 463ba1c9 <unknown>
36 *
37 * code around pc:
38 * 463ba1e4 4300e119 4284aa7a f927f7b7 40112268
39 * 463ba1f4 419da7f8 00002000 01000100 00080000
40 * 463ba204 4191debc 01010000 4284aa74 68b00054
41 * 463ba214 045cf205 cc016468 0718f2a5 d0102800
42 * 463ba224 4c13c701 a20aa108 efb0f775 e008e010
43 *
44 * code around lr:
45 * 463ba1a8 42e19e58 f2050050 cc01045c 0718f2a5
46 * 463ba1b8 d00f2800 4c13c701 a20aa108 efe4f775
47 * 463ba1c8 e007e010 29006bf8 6e77dc01 a10347b8
48 * 463ba1d8 ef60f775 6db1480b 1c2d4788 4300e119
49 * 463ba1e8 4284aa7a f927f7b7 40112268 419da7f8
50 *
51 */
52
53 int codePC[] = {
54 // Sample content
55 0x4300e119, 0x4284aa7a, 0xf927f7b7, 0x40112268,
56 0x419da7f8, 0x00002000, 0x01000100, 0x00080000,
57 0x4191debc, 0x01010000, 0x4284aa74, 0x68b00054,
58 0x045cf205, 0xcc016468, 0x0718f2a5, 0xd0102800,
59 0x4c13c701, 0xa20aa108, 0xefb0f775, 0xe008e010,
60 };
61
62 int codeLR[] = {
63 // Sample content
64 0x42e19e58, 0xf2050050, 0xcc01045c, 0x0718f2a5,
65 0xd00f2800, 0x4c13c701, 0xa20aa108, 0xefe4f775,
66 0xe007e010, 0x29006bf8, 0x6e77dc01, 0xa10347b8,
67 0xef60f775, 0x6db1480b, 0x1c2d4788, 0x4300e119,
68 0x4284aa7a, 0xf927f7b7, 0x40112268, 0x419da7f8,
69 };
70
71 /* For example: 463ba1e4 & 0xfff */
72 #define START_PC_PAGE_OFFSET 0x1e4
73
74 /* For example: 463ba1a8 & 0xfff */
75 #define START_LR_PAGE_OFFSET 0x1a8
76
77 /* Each points to a two-page buffer */
78 char *codePCCache, *codeLRCache;
79
dumpCode(int * pc,int * lr)80 void dumpCode(int *pc, int *lr)
81 {
82 unsigned int i;
83
84 for (i = 0; i < NUM_DUMPED_WORDS; i++) {
85 printf("%p codePC[%d]: %#010x\n", pc + i, i, pc[i]);
86 }
87
88 for (i = 0; i < NUM_DUMPED_WORDS; i++) {
89 printf("%p codeLR[%d]: %#010x\n", lr + i, i, lr[i]);
90 }
91 }
92
main()93 int main()
94 {
95 codePCCache = memalign(4096, 8192);
96 codeLRCache = memalign(4096, 8192);
97
98 memcpy(codePCCache + START_PC_PAGE_OFFSET, codePC, 4 * NUM_DUMPED_WORDS);
99 memcpy(codeLRCache + START_LR_PAGE_OFFSET, codeLR, 4 * NUM_DUMPED_WORDS);
100
101 dumpCode((int *) (codePCCache + START_PC_PAGE_OFFSET),
102 (int *) (codeLRCache + START_LR_PAGE_OFFSET));
103
104 while (!done) {
105 sleep(1000);
106 }
107 return 0;
108 }
109