Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
43ff203d
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
43ff203d
编写于
7月 25, 2011
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use variadic macros for debugging
Looks *so* much nicer!
上级
decd4e3e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
60 deletion
+56
-60
src/hb-blob.cc
src/hb-blob.cc
+13
-13
src/hb-object-private.hh
src/hb-object-private.hh
+4
-4
src/hb-open-type-private.hh
src/hb-open-type-private.hh
+34
-41
src/hb-private.hh
src/hb-private.hh
+5
-2
未找到文件。
src/hb-blob.cc
浏览文件 @
43ff203d
...
...
@@ -243,27 +243,27 @@ _try_make_writable_inplace_unix (hb_blob_t *blob)
#endif
if
((
uintptr_t
)
-
1L
==
pagesize
)
{
DEBUG
(
BLOB
,
fprintf
(
stderr
,
"%p %s: failed to get pagesize: %s
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
strerror
(
errno
)
));
DEBUG
_MSG
(
BLOB
,
"%p %s: failed to get pagesize: %s
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
strerror
(
errno
));
return
FALSE
;
}
DEBUG
(
BLOB
,
fprintf
(
stderr
,
"%p %s: pagesize is %lu
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
(
unsigned
long
)
pagesize
)
);
DEBUG
_MSG
(
BLOB
,
"%p %s: pagesize is %lu
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
(
unsigned
long
)
pagesize
);
mask
=
~
(
pagesize
-
1
);
addr
=
(
const
char
*
)
(((
uintptr_t
)
blob
->
data
)
&
mask
);
length
=
(
const
char
*
)
(((
uintptr_t
)
blob
->
data
+
blob
->
length
+
pagesize
-
1
)
&
mask
)
-
addr
;
DEBUG
(
BLOB
,
fprintf
(
stderr
,
"%p %s: calling mprotect on [%p..%p] (%lu bytes)
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
addr
,
addr
+
length
,
(
unsigned
long
)
length
)
);
DEBUG
_MSG
(
BLOB
,
"%p %s: calling mprotect on [%p..%p] (%lu bytes)
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
addr
,
addr
+
length
,
(
unsigned
long
)
length
);
if
(
-
1
==
mprotect
((
void
*
)
addr
,
length
,
PROT_READ
|
PROT_WRITE
))
{
DEBUG
(
BLOB
,
fprintf
(
stderr
,
"%p %s: %s
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
strerror
(
errno
)
));
DEBUG
_MSG
(
BLOB
,
"%p %s: %s
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
strerror
(
errno
));
return
FALSE
;
}
blob
->
mode
=
HB_MEMORY_MODE_WRITABLE
;
DEBUG
(
BLOB
,
fprintf
(
stderr
,
"%p %s: successfully made [%p..%p] (%lu bytes) writable
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
addr
,
addr
+
length
,
(
unsigned
long
)
length
)
);
DEBUG
_MSG
(
BLOB
,
"%p %s: successfully made [%p..%p] (%lu bytes) writable
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
addr
,
addr
+
length
,
(
unsigned
long
)
length
);
return
TRUE
;
#else
return
FALSE
;
...
...
@@ -273,12 +273,12 @@ _try_make_writable_inplace_unix (hb_blob_t *blob)
static
bool
_try_writable_inplace
(
hb_blob_t
*
blob
)
{
DEBUG
(
BLOB
,
fprintf
(
stderr
,
"%p %s: making writable inplace
\n
"
,
(
void
*
)
blob
,
HB_FUNC
)
);
DEBUG
_MSG
(
BLOB
,
"%p %s: making writable inplace
\n
"
,
(
void
*
)
blob
,
HB_FUNC
);
if
(
_try_make_writable_inplace_unix
(
blob
))
return
TRUE
;
DEBUG
(
BLOB
,
fprintf
(
stderr
,
"%p %s: making writable -> FAILED
\n
"
,
(
void
*
)
blob
,
HB_FUNC
)
);
DEBUG
_MSG
(
BLOB
,
"%p %s: making writable -> FAILED
\n
"
,
(
void
*
)
blob
,
HB_FUNC
);
/* Failed to make writable inplace, mark that */
blob
->
mode
=
HB_MEMORY_MODE_READONLY
;
...
...
@@ -301,7 +301,7 @@ _try_writable (hb_blob_t *blob)
return
TRUE
;
DEBUG
(
BLOB
,
fprintf
(
stderr
,
"%p %s -> %p
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
blob
->
data
)
);
DEBUG
_MSG
(
BLOB
,
"%p %s -> %p
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
blob
->
data
);
char
*
new_data
;
...
...
@@ -309,7 +309,7 @@ _try_writable (hb_blob_t *blob)
if
(
unlikely
(
!
new_data
))
return
FALSE
;
DEBUG
(
BLOB
,
fprintf
(
stderr
,
"%p %s: dupped successfully -> %p
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
blob
->
data
)
);
DEBUG
_MSG
(
BLOB
,
"%p %s: dupped successfully -> %p
\n
"
,
(
void
*
)
blob
,
HB_FUNC
,
blob
->
data
);
memcpy
(
new_data
,
blob
->
data
,
blob
->
length
);
_hb_blob_destroy_user_data
(
blob
);
...
...
src/hb-object-private.hh
浏览文件 @
43ff203d
...
...
@@ -191,10 +191,10 @@ struct _hb_object_header_t {
}
inline
void
trace
(
const
char
*
function
)
const
{
DEBUG
(
OBJECT
,
fprintf
(
stderr
,
"OBJECT(%p) refcount=%d %s
\n
"
,
(
void
*
)
this
,
this
?
ref_count
.
get
()
:
0
,
function
)
);
DEBUG
_MSG
(
OBJECT
,
"OBJECT(%p) refcount=%d %s
\n
"
,
(
void
*
)
this
,
this
?
ref_count
.
get
()
:
0
,
function
);
}
};
...
...
src/hb-open-type-private.hh
浏览文件 @
43ff203d
...
...
@@ -196,17 +196,15 @@ struct hb_sanitize_context_t
this
->
edit_count
=
0
;
this
->
debug_depth
=
0
;
(
void
)
(
HB_DEBUG_SANITIZE
&&
fprintf
(
stderr
,
"sanitize %p init [%p..%p] (%lu bytes)
\n
"
,
(
void
*
)
this
->
blob
,
this
->
start
,
this
->
end
,
(
unsigned
long
)
(
this
->
end
-
this
->
start
)));
DEBUG_MSG
(
SANITIZE
,
"sanitize %p init [%p..%p] (%lu bytes)
\n
"
,
(
void
*
)
this
->
blob
,
this
->
start
,
this
->
end
,
(
unsigned
long
)
(
this
->
end
-
this
->
start
));
}
inline
void
finish
(
void
)
{
(
void
)
(
HB_DEBUG_SANITIZE
&&
fprintf
(
stderr
,
"sanitize %p fini [%p..%p] %u edit requests
\n
"
,
(
void
*
)
this
->
blob
,
this
->
start
,
this
->
end
,
this
->
edit_count
));
DEBUG_MSG
(
SANITIZE
,
"sanitize %p fini [%p..%p] %u edit requests
\n
"
,
(
void
*
)
this
->
blob
,
this
->
start
,
this
->
end
,
this
->
edit_count
);
hb_blob_destroy
(
this
->
blob
);
this
->
blob
=
NULL
;
...
...
@@ -220,13 +218,13 @@ struct hb_sanitize_context_t
p
<=
this
->
end
&&
(
unsigned
int
)
(
this
->
end
-
p
)
>=
len
;
DEBUG_
DEPTH
(
SANITIZE
,
this
->
debug_depth
,
fprintf
(
stderr
,
"SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s
\n
"
,
p
,
this
->
debug_depth
,
this
->
debug_depth
,
p
,
p
+
len
,
len
,
this
->
start
,
this
->
end
,
ret
?
"pass"
:
"FAIL"
)
);
DEBUG_
MSG_LEVEL
(
SANITIZE
,
this
->
debug_depth
,
"SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s
\n
"
,
p
,
this
->
debug_depth
,
this
->
debug_depth
,
p
,
p
+
len
,
len
,
this
->
start
,
this
->
end
,
ret
?
"pass"
:
"FAIL"
);
return
likely
(
ret
);
}
...
...
@@ -236,13 +234,13 @@ struct hb_sanitize_context_t
const
char
*
p
=
(
const
char
*
)
base
;
bool
overflows
=
_hb_unsigned_int_mul_overflows
(
len
,
record_size
);
DEBUG_
DEPTH
(
SANITIZE
,
this
->
debug_depth
,
fprintf
(
stderr
,
"SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s
\n
"
,
p
,
this
->
debug_depth
,
this
->
debug_depth
,
p
,
p
+
(
record_size
*
len
),
record_size
,
len
,
(
unsigned
long
)
record_size
*
len
,
this
->
start
,
this
->
end
,
!
overflows
?
"does not overflow"
:
"OVERFLOWS FAIL"
)
);
DEBUG_
MSG_LEVEL
(
SANITIZE
,
this
->
debug_depth
,
"SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s
\n
"
,
p
,
this
->
debug_depth
,
this
->
debug_depth
,
p
,
p
+
(
record_size
*
len
),
record_size
,
len
,
(
unsigned
long
)
record_size
*
len
,
this
->
start
,
this
->
end
,
!
overflows
?
"does not overflow"
:
"OVERFLOWS FAIL"
);
return
likely
(
!
overflows
&&
this
->
check_range
(
base
,
record_size
*
len
));
}
...
...
@@ -258,14 +256,14 @@ struct hb_sanitize_context_t
const
char
*
p
=
(
const
char
*
)
base
;
this
->
edit_count
++
;
DEBUG_
DEPTH
(
SANITIZE
,
this
->
debug_depth
,
fprintf
(
stderr
,
"SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s
\n
"
,
p
,
this
->
debug_depth
,
this
->
debug_depth
,
this
->
edit_count
,
p
,
p
+
len
,
len
,
this
->
start
,
this
->
end
,
this
->
writable
?
"granted"
:
"REJECTED"
)
);
DEBUG_
MSG_LEVEL
(
SANITIZE
,
this
->
debug_depth
,
"SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s
\n
"
,
p
,
this
->
debug_depth
,
this
->
debug_depth
,
this
->
edit_count
,
p
,
p
+
len
,
len
,
this
->
start
,
this
->
end
,
this
->
writable
?
"granted"
:
"REJECTED"
);
return
this
->
writable
;
}
...
...
@@ -292,8 +290,7 @@ struct Sanitizer
c
->
init
(
blob
);
retry:
(
void
)
(
HB_DEBUG_SANITIZE
&&
fprintf
(
stderr
,
"Sanitizer %p start %s
\n
"
,
(
void
*
)
blob
,
HB_FUNC
));
DEBUG_MSG
(
SANITIZE
,
"Sanitizer %p start %s
\n
"
,
(
void
*
)
blob
,
HB_FUNC
);
c
->
setup
();
...
...
@@ -307,17 +304,15 @@ struct Sanitizer
sane
=
t
->
sanitize
(
c
);
if
(
sane
)
{
if
(
c
->
edit_count
)
{
(
void
)
(
HB_DEBUG_SANITIZE
&&
fprintf
(
stderr
,
"Sanitizer %p passed first round with %d edits; doing a second round %s
\n
"
,
(
void
*
)
blob
,
c
->
edit_count
,
HB_FUNC
));
DEBUG_MSG
(
SANITIZE
,
"Sanitizer %p passed first round with %d edits; doing a second round %s
\n
"
,
(
void
*
)
blob
,
c
->
edit_count
,
HB_FUNC
);
/* sanitize again to ensure no toe-stepping */
c
->
edit_count
=
0
;
sane
=
t
->
sanitize
(
c
);
if
(
c
->
edit_count
)
{
(
void
)
(
HB_DEBUG_SANITIZE
&&
fprintf
(
stderr
,
"Sanitizer %p requested %d edits in second round; FAILLING %s
\n
"
,
(
void
*
)
blob
,
c
->
edit_count
,
HB_FUNC
));
DEBUG_MSG
(
SANITIZE
,
"Sanitizer %p requested %d edits in second round; FAILLING %s
\n
"
,
(
void
*
)
blob
,
c
->
edit_count
,
HB_FUNC
);
sane
=
false
;
}
}
...
...
@@ -330,8 +325,7 @@ struct Sanitizer
if
(
c
->
start
)
{
c
->
writable
=
true
;
/* ok, we made it writable by relocating. try again */
(
void
)
(
HB_DEBUG_SANITIZE
&&
fprintf
(
stderr
,
"Sanitizer %p retry %s
\n
"
,
(
void
*
)
blob
,
HB_FUNC
));
DEBUG_MSG
(
SANITIZE
,
"Sanitizer %p retry %s
\n
"
,
(
void
*
)
blob
,
HB_FUNC
);
goto
retry
;
}
}
...
...
@@ -339,8 +333,7 @@ struct Sanitizer
c
->
finish
();
(
void
)
(
HB_DEBUG_SANITIZE
&&
fprintf
(
stderr
,
"Sanitizer %p %s %s
\n
"
,
(
void
*
)
blob
,
sane
?
"passed"
:
"FAILED"
,
HB_FUNC
));
DEBUG_MSG
(
SANITIZE
,
"Sanitizer %p %s %s
\n
"
,
(
void
*
)
blob
,
sane
?
"passed"
:
"FAILED"
,
HB_FUNC
);
if
(
sane
)
return
blob
;
else
{
...
...
src/hb-private.hh
浏览文件 @
43ff203d
...
...
@@ -466,8 +466,11 @@ static inline unsigned char TOLOWER (unsigned char c)
#define HB_DEBUG 0
#endif
#define DEBUG(WHAT, CODE) (void) (HB_DEBUG_##WHAT && (CODE))
#define DEBUG_DEPTH(WHAT, DEPTH, CODE) (void) (HB_DEBUG_##WHAT && (int) (DEPTH) < (int) (HB_DEBUG_##WHAT) && (CODE))
#define DEBUG_LEVEL(WHAT, LEVEL) (HB_DEBUG_##WHAT && (int) (LEVEL) < (int) (HB_DEBUG_##WHAT))
#define DEBUG(WHAT) (DEBUG_LEVEL (WHAT, 0))
#define DEBUG_MSG_LEVEL(WHAT, LEVEL, ...) (void) (DEBUG_LEVEL (WHAT, LEVEL) && fprintf (stderr, __VA_ARGS__))
#define DEBUG_MSG(WHAT, ...) DEBUG_MSG_LEVEL (WHAT, 0, __VA_ARGS__)
static
inline
bool
/* always returns TRUE */
_hb_trace
(
const
char
*
what
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录