Commit 8c18566f authored by Lubomir Bulej's avatar Lubomir Bulej
Browse files

Don't pass string length to messager functions

The JVM's modified UTF-8 encoding ensures that C-style strings are
properly terminated by a single NUL character.
parent d30fa0ad
......@@ -130,9 +130,7 @@ __register_method (
process_buffs * buffs = pb_utility_get ();
jshort new_analysis_id = __next_analysis_id ();
messager_reganalysis (
buffs->analysis_buff, new_analysis_id, utf_str, utf_len
);
messager_reganalysis (buffs->analysis_buff, new_analysis_id, utf_str);
sender_enqueue (buffs);
......
......@@ -146,9 +146,7 @@ messager_classinfo (
void
messager_stringinfo (
buffer_t * buffer, jlong str_tag, const char * str, jsize str_len
) {
messager_stringinfo (buffer_t * buffer, jlong str_tag, jvm_utf8_t str) {
StringInfo stringInfo = STRING_INFO__INIT;
stringInfo.stringtag = str_tag;
stringInfo.stringdata = (char *) str;
......@@ -163,10 +161,7 @@ messager_stringinfo (
void
messager_reganalysis (
buffer_t * buffer, jshort analysis_id,
const char * descriptor, jsize descriptor_len
) {
messager_reganalysis (buffer_t * buffer, jshort analysis_id, jvm_utf8_t descriptor) {
RegisterAnalysis registerAnalysis = REGISTER_ANALYSIS__INIT;
registerAnalysis.analysisid = analysis_id;
registerAnalysis.descriptor = (char *) descriptor;
......@@ -182,8 +177,7 @@ messager_reganalysis (
void
messager_threadinfo (
buffer_t * buffer, jlong thread_tag, const char * name,
jsize name_len, jboolean is_daemon
buffer_t * buffer, jlong thread_tag, jvm_utf8_t name, jboolean is_daemon
) {
ThreadInfo threadInfo = THREAD_INFO__INIT;
threadInfo.threadtag = thread_tag;
......
......@@ -10,6 +10,8 @@
#define MSG_ANALYZE 1 // sending analysis
#define MSG_OBJ_FREE 2 // sending object free
typedef const char * jvm_utf8_t;
//
#define MSG_ANALYZE_HEADER_SIZE (sizeof (uint8_t) + sizeof (jlong) + sizeof (jint))
......@@ -32,18 +34,12 @@ void messager_classinfo (
const char * class_gen, jlong loader_tag, jlong super_class_tag
);
void messager_stringinfo (
buffer_t * buffer, jlong str_tag, const char * str, jsize str_len
);
void messager_stringinfo (buffer_t * buffer, jlong str_tag, jvm_utf8_t str);
void messager_reganalysis (
buffer_t * buffer, jshort analysis_id,
const char * descriptor, jsize descriptor_len
);
void messager_reganalysis (buffer_t * buffer, jshort analysis_id, jvm_utf8_t descriptor);
void messager_threadinfo (
buffer_t * buffer, jlong thread_tag,
const char * name, jsize name_len, jboolean is_daemon
buffer_t * buffer, jlong thread_tag, jvm_utf8_t name, jboolean is_daemon
);
void messager_threadend (buffer_t * buffer, jlong thread_id);
......
......@@ -42,7 +42,7 @@ ot_pack_string_data (
const char * utf = (*jni)->GetStringUTFChars (jni, string, NULL /* copy */);
check_error (utf == NULL, "failed to get UTF data for string");
messager_stringinfo (buffer, netref, utf, utf_len);
messager_stringinfo (buffer, netref, utf);
// Release the UTF data.
(*jni)->ReleaseStringUTFChars (jni, string, utf);
......@@ -59,9 +59,7 @@ ot_pack_thread_data (
check_jvmti_error (jvmti, error, "failed to get thread info");
// pack thread info message
messager_threadinfo (
buffer, netref, info.name, strlen (info.name), info.is_daemon
);
messager_threadinfo (buffer, netref, info.name, info.is_daemon);
// Release the contents of thread info.
(*jvmti)->Deallocate (jvmti, (unsigned char *) info.name);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment