1// Copyright 2016 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import {
6    CppProcessor, LinuxCppEntriesProvider
7  } from "../../../tools/dumpcpp.mjs" ;
8
9await (async function testProcessSharedLibrary() {
10  var oldLoadSymbols = LinuxCppEntriesProvider.prototype.loadSymbols;
11
12  LinuxCppEntriesProvider.prototype.loadSymbols = function(libName) {
13    this.symbols = [[
14      '00000100 00000001 t v8::internal::Runtime_StringReplaceRegExpWithString(v8::internal::Arguments)',
15      '00000110 00000001 T v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle<v8::internal::Object>, unsigned int)',
16      '00000120 00000001 t v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Arguments)',
17      '00000130 00000001 W v8::internal::RegExpMacroAssembler::CheckPosition(int, v8::internal::Label*)'
18    ].join('\n'), ''];
19  };
20
21  var testCppProcessor = new CppProcessor(new LinuxCppEntriesProvider(),
22                                          false, false);
23  await testCppProcessor.processSharedLibrary(
24    '/usr/local/google/home/lpy/v8/out/native/d8',
25    0x00000100, 0x00000400, 0);
26
27  var staticEntries = testCppProcessor.codeMap_.getAllStaticEntriesWithAddresses();
28  var total = staticEntries.length;
29  assertEquals(total, 3);
30  assertEquals(staticEntries[0],
31               [288,{size:1,
32                     name:'v8::internal::Runtime_DebugGetPropertyDetails(v8::internal::Arguments)',
33                     type:'CPP',
34                     nameUpdated_:false,
35                     source: undefined,
36                }
37               ]);
38  assertEquals(staticEntries[1],
39               [272,{size:1,
40                     name:'v8::internal::Runtime::GetElementOrCharAt(v8::internal::Handle<v8::internal::Object>, unsigned int)',
41                     type:'CPP',
42                     nameUpdated_:false,
43                     source: undefined,
44                }
45               ]);
46  assertEquals(staticEntries[2],
47              [256,{size:1,
48                    name:'v8::internal::Runtime_StringReplaceRegExpWithString(v8::internal::Arguments)',
49                    type:'CPP',
50                    nameUpdated_:false,
51                    source: undefined,
52                }
53              ]);
54
55  LinuxCppEntriesProvider.prototype.loadSymbols = oldLoadSymbols;
56})();
57