Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
75072520
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
75072520
编写于
7月 31, 2012
作者:
D
dcubed
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
0bc2e2f1
3ab35541
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
195 addition
and
6 deletion
+195
-6
src/os/bsd/vm/decoder_machO.cpp
src/os/bsd/vm/decoder_machO.cpp
+133
-0
src/os/bsd/vm/decoder_machO.hpp
src/os/bsd/vm/decoder_machO.hpp
+17
-2
src/os/bsd/vm/os_bsd.cpp
src/os/bsd/vm/os_bsd.cpp
+14
-0
src/os/windows/vm/decoder_windows.cpp
src/os/windows/vm/decoder_windows.cpp
+2
-2
src/os/windows/vm/decoder_windows.hpp
src/os/windows/vm/decoder_windows.hpp
+4
-0
src/share/vm/utilities/decoder.cpp
src/share/vm/utilities/decoder.cpp
+12
-0
src/share/vm/utilities/decoder.hpp
src/share/vm/utilities/decoder.hpp
+7
-0
src/share/vm/utilities/decoder_elf.hpp
src/share/vm/utilities/decoder_elf.hpp
+4
-0
src/share/vm/utilities/hashtable.cpp
src/share/vm/utilities/hashtable.cpp
+1
-1
src/share/vm/utilities/hashtable.hpp
src/share/vm/utilities/hashtable.hpp
+1
-1
未找到文件。
src/os/bsd/vm/decoder_machO.cpp
浏览文件 @
75072520
...
...
@@ -26,6 +26,139 @@
#ifdef __APPLE__
#include "decoder_machO.hpp"
#include <cxxabi.h>
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
bool
MachODecoder
::
demangle
(
const
char
*
symbol
,
char
*
buf
,
int
buflen
)
{
int
status
;
char
*
result
;
size_t
size
=
(
size_t
)
buflen
;
// Don't pass buf to __cxa_demangle. In case of the 'buf' is too small,
// __cxa_demangle will call system "realloc" for additional memory, which
// may use different malloc/realloc mechanism that allocates 'buf'.
if
((
result
=
abi
::
__cxa_demangle
(
symbol
,
NULL
,
NULL
,
&
status
))
!=
NULL
)
{
jio_snprintf
(
buf
,
buflen
,
"%s"
,
result
);
// call c library's free
::
free
(
result
);
return
true
;
}
return
false
;
}
bool
MachODecoder
::
decode
(
address
addr
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
void
*
mach_base
)
{
struct
symtab_command
*
symt
=
(
struct
symtab_command
*
)
mach_find_command
((
struct
mach_header_64
*
)
mach_base
,
LC_SYMTAB
);
if
(
symt
==
NULL
)
{
DEBUG_ONLY
(
tty
->
print_cr
(
"no symtab in mach file at 0x%lx"
,
mach_base
));
return
false
;
}
uint32_t
off
=
symt
->
symoff
;
/* symbol table offset (within this mach file) */
uint32_t
nsyms
=
symt
->
nsyms
;
/* number of symbol table entries */
uint32_t
stroff
=
symt
->
stroff
;
/* string table offset */
uint32_t
strsize
=
symt
->
strsize
;
/* string table size in bytes */
// iterate through symbol table trying to match our offset
uint32_t
addr_relative
=
(
uintptr_t
)
mach_base
-
(
uintptr_t
)
addr
;
// offset we seek in the symtab
void
*
symtab_addr
=
(
void
*
)
((
uintptr_t
)
mach_base
+
off
);
struct
nlist_64
*
cur_nlist
=
(
struct
nlist_64
*
)
symtab_addr
;
struct
nlist_64
*
last_nlist
=
cur_nlist
;
// no size stored in an entry, so keep previously seen nlist
int32_t
found_strx
=
0
;
int32_t
found_symval
=
0
;
for
(
uint32_t
i
=
0
;
i
<
nsyms
;
i
++
)
{
uint32_t
this_value
=
cur_nlist
->
n_value
;
if
(
addr_relative
==
this_value
)
{
found_strx
=
cur_nlist
->
n_un
.
n_strx
;
found_symval
=
this_value
;
break
;
}
else
if
(
addr_relative
>
this_value
)
{
// gone past it, use previously seen nlist:
found_strx
=
last_nlist
->
n_un
.
n_strx
;
found_symval
=
last_nlist
->
n_value
;
break
;
}
last_nlist
=
cur_nlist
;
cur_nlist
=
cur_nlist
+
sizeof
(
struct
nlist_64
);
}
if
(
found_strx
==
0
)
{
return
false
;
}
// write the offset:
*
offset
=
addr_relative
-
found_symval
;
// lookup found_strx in the string table
char
*
symname
=
mach_find_in_stringtable
((
char
*
)
((
uintptr_t
)
mach_base
+
stroff
),
strsize
,
found_strx
);
if
(
symname
)
{
strncpy
(
buf
,
symname
,
buflen
);
return
true
;
}
DEBUG_ONLY
(
tty
->
print_cr
(
"no string or null string found."
));
return
false
;
}
void
*
MachODecoder
::
mach_find_command
(
struct
mach_header_64
*
mach_base
,
uint32_t
command_wanted
)
{
// possibly verify it is a mach_header, use magic number.
// commands begin immediately after the header.
struct
load_command
*
pos
=
(
struct
load_command
*
)
mach_base
+
sizeof
(
struct
mach_header_64
);
for
(
uint32_t
i
=
0
;
i
<
mach_base
->
ncmds
;
i
++
)
{
struct
load_command
*
this_cmd
=
(
struct
load_command
*
)
pos
;
if
(
this_cmd
->
cmd
==
command_wanted
)
{
return
pos
;
}
int
cmdsize
=
this_cmd
->
cmdsize
;
pos
+=
cmdsize
;
}
return
NULL
;
}
char
*
MachODecoder
::
mach_find_in_stringtable
(
char
*
strtab
,
uint32_t
tablesize
,
int
strx_wanted
)
{
if
(
strx_wanted
==
0
)
{
return
NULL
;
}
char
*
strtab_end
=
strtab
+
tablesize
;
// find the first string, skip over the space char
// (or the four zero bytes we see e.g. in libclient)
if
(
*
strtab
==
' '
)
{
strtab
++
;
if
(
*
strtab
!=
0
)
{
DEBUG_ONLY
(
tty
->
print_cr
(
"string table has leading space but no following zero."
));
return
NULL
;
}
strtab
++
;
}
else
{
if
((
uint32_t
)
*
strtab
!=
0
)
{
DEBUG_ONLY
(
tty
->
print_cr
(
"string table without leading space or leading int of zero."
));
return
NULL
;
}
strtab
+=
4
;
}
// read the real strings starting at index 1
int
cur_strx
=
1
;
while
(
strtab
<
strtab_end
)
{
if
(
cur_strx
==
strx_wanted
)
{
return
strtab
;
}
// find start of next string
while
(
*
strtab
!=
0
)
{
strtab
++
;
}
strtab
++
;
// skip the terminating zero
cur_strx
++
;
}
DEBUG_ONLY
(
tty
->
print_cr
(
"string number %d not found."
,
strx_wanted
));
return
NULL
;
}
#endif
src/os/bsd/vm/decoder_machO.hpp
浏览文件 @
75072520
...
...
@@ -31,10 +31,25 @@
// Just a placehold for now, a real implementation should derive
// from AbstractDecoder
class
MachODecoder
:
public
Null
Decoder
{
public:
class
MachODecoder
:
public
Abstract
Decoder
{
public:
MachODecoder
()
{
}
~
MachODecoder
()
{
}
virtual
bool
can_decode_C_frame_in_vm
()
const
{
return
true
;
}
virtual
bool
demangle
(
const
char
*
symbol
,
char
*
buf
,
int
buflen
);
virtual
bool
decode
(
address
pc
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
void
*
base
);
virtual
bool
decode
(
address
pc
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
char
*
module_path
=
NULL
)
{
ShouldNotReachHere
();
return
false
;
}
private:
void
*
mach_find_command
(
struct
mach_header_64
*
mach_base
,
uint32_t
command_wanted
);
char
*
mach_find_in_stringtable
(
char
*
strtab
,
uint32_t
tablesize
,
int
strx_wanted
);
};
#endif
...
...
src/os/bsd/vm/os_bsd.cpp
浏览文件 @
75072520
...
...
@@ -1946,10 +1946,16 @@ bool os::address_is_in_vm(address addr) {
return
false
;
}
#define MACH_MAXSYMLEN 256
bool
os
::
dll_address_to_function_name
(
address
addr
,
char
*
buf
,
int
buflen
,
int
*
offset
)
{
Dl_info
dlinfo
;
char
localbuf
[
MACH_MAXSYMLEN
];
// dladdr will find names of dynamic functions only, but does
// it set dli_fbase with mach_header address when it "fails" ?
if
(
dladdr
((
void
*
)
addr
,
&
dlinfo
)
&&
dlinfo
.
dli_sname
!=
NULL
)
{
if
(
buf
!=
NULL
)
{
if
(
!
Decoder
::
demangle
(
dlinfo
.
dli_sname
,
buf
,
buflen
))
{
...
...
@@ -1965,6 +1971,14 @@ bool os::dll_address_to_function_name(address addr, char *buf,
}
}
// Handle non-dymanic manually:
if
(
dlinfo
.
dli_fbase
!=
NULL
&&
Decoder
::
decode
(
addr
,
localbuf
,
MACH_MAXSYMLEN
,
offset
,
dlinfo
.
dli_fbase
))
{
if
(
!
Decoder
::
demangle
(
localbuf
,
buf
,
buflen
))
{
jio_snprintf
(
buf
,
buflen
,
"%s"
,
localbuf
);
}
return
true
;
}
if
(
buf
!=
NULL
)
buf
[
0
]
=
'\0'
;
if
(
offset
!=
NULL
)
*
offset
=
-
1
;
return
false
;
...
...
src/os/windows/vm/decoder_windows.cpp
浏览文件 @
75072520
...
...
@@ -72,10 +72,10 @@ void WindowsDecoder::initialize() {
// find out if jvm.dll contains private symbols, by decoding
// current function and comparing the result
address
addr
=
(
address
)
Decoder
::
de
cod
e
;
address
addr
=
(
address
)
Decoder
::
de
mangl
e
;
char
buf
[
MAX_PATH
];
if
(
decode
(
addr
,
buf
,
sizeof
(
buf
),
NULL
))
{
_can_decode_in_vm
=
!
strcmp
(
buf
,
"Decoder::de
cod
e"
);
_can_decode_in_vm
=
!
strcmp
(
buf
,
"Decoder::de
mangl
e"
);
}
}
}
...
...
src/os/windows/vm/decoder_windows.hpp
浏览文件 @
75072520
...
...
@@ -45,6 +45,10 @@ public:
bool
can_decode_C_frame_in_vm
()
const
;
bool
demangle
(
const
char
*
symbol
,
char
*
buf
,
int
buflen
);
bool
decode
(
address
addr
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
char
*
modulepath
=
NULL
);
bool
decode
(
address
addr
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
void
*
base
)
{
ShouldNotReachHere
();
return
false
;
}
private:
void
initialize
();
...
...
src/share/vm/utilities/decoder.cpp
浏览文件 @
75072520
...
...
@@ -91,6 +91,18 @@ bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const cha
return
decoder
->
decode
(
addr
,
buf
,
buflen
,
offset
,
modulepath
);
}
bool
Decoder
::
decode
(
address
addr
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
void
*
base
)
{
assert
(
_shared_decoder_lock
!=
NULL
,
"Just check"
);
bool
error_handling_thread
=
os
::
current_thread_id
()
==
VMError
::
first_error_tid
;
MutexLockerEx
locker
(
error_handling_thread
?
NULL
:
_shared_decoder_lock
,
true
);
AbstractDecoder
*
decoder
=
error_handling_thread
?
get_error_handler_instance
()
:
get_shared_instance
();
assert
(
decoder
!=
NULL
,
"null decoder"
);
return
decoder
->
decode
(
addr
,
buf
,
buflen
,
offset
,
base
);
}
bool
Decoder
::
demangle
(
const
char
*
symbol
,
char
*
buf
,
int
buflen
)
{
assert
(
_shared_decoder_lock
!=
NULL
,
"Just check"
);
bool
error_handling_thread
=
os
::
current_thread_id
()
==
VMError
::
first_error_tid
;
...
...
src/share/vm/utilities/decoder.hpp
浏览文件 @
75072520
...
...
@@ -47,6 +47,8 @@ public:
// the function
virtual
bool
decode
(
address
pc
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
char
*
modulepath
=
NULL
)
=
0
;
virtual
bool
decode
(
address
pc
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
void
*
base
)
=
0
;
// demangle a C++ symbol
virtual
bool
demangle
(
const
char
*
symbol
,
char
*
buf
,
int
buflen
)
=
0
;
// if the decoder can decode symbols in vm
...
...
@@ -82,6 +84,10 @@ public:
return
false
;
}
virtual
bool
decode
(
address
pc
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
void
*
base
)
{
return
false
;
}
virtual
bool
demangle
(
const
char
*
symbol
,
char
*
buf
,
int
buflen
)
{
return
false
;
}
...
...
@@ -95,6 +101,7 @@ public:
class
Decoder
:
AllStatic
{
public:
static
bool
decode
(
address
pc
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
char
*
modulepath
=
NULL
);
static
bool
decode
(
address
pc
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
void
*
base
);
static
bool
demangle
(
const
char
*
symbol
,
char
*
buf
,
int
buflen
);
static
bool
can_decode_C_frame_in_vm
();
...
...
src/share/vm/utilities/decoder_elf.hpp
浏览文件 @
75072520
...
...
@@ -43,6 +43,10 @@ public:
bool
demangle
(
const
char
*
symbol
,
char
*
buf
,
int
buflen
);
bool
decode
(
address
addr
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
char
*
filepath
=
NULL
);
bool
decode
(
address
addr
,
char
*
buf
,
int
buflen
,
int
*
offset
,
const
void
*
base
)
{
ShouldNotReachHere
();
return
false
;
}
private:
ElfFile
*
get_elf_file
(
const
char
*
filepath
);
...
...
src/share/vm/utilities/hashtable.cpp
浏览文件 @
75072520
...
...
@@ -135,7 +135,7 @@ template <class T, MEMFLAGS F> void Hashtable<T, F>::move_to(Hashtable<T, F>* ne
// walking the hashtable past these entries requires
// BasicHashtableEntry::make_ptr() call.
bool
keep_shared
=
p
->
is_shared
();
unlink_entry
(
p
);
this
->
unlink_entry
(
p
);
new_table
->
add_entry
(
index
,
p
);
if
(
keep_shared
)
{
p
->
set_shared
();
...
...
src/share/vm/utilities/hashtable.hpp
浏览文件 @
75072520
...
...
@@ -260,7 +260,7 @@ protected:
}
int
index_for
(
Symbol
*
name
)
{
return
hash_to_index
(
compute_hash
(
name
));
return
this
->
hash_to_index
(
compute_hash
(
name
));
}
// Table entry management
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录