Commit 734ce441 authored by Vít Kabele's avatar Vít Kabele

Error checks and atExit event call added.

parent 16fd0d59
......@@ -19,7 +19,7 @@ final class RequestDispatcher {
__shadowVM = shadowVM;
}
void ProcessMessage(final AgentMessage agentMessage) {
void ProcessMessage(final AgentMessage agentMessage) throws DiSLREServerException {
switch (agentMessage.getRequestCase ())
{
......
......@@ -74,16 +74,15 @@ public class SHVM implements ISHVM {
* @param rawData Packed raw data
*/
@Override
public void HandleAnalyze (byte[] rawData)
public void HandleAnalyze (byte[] rawData) throws DiSLREServerException
{
try {
__anlHndl
.handle (
new DataInputStream (new ByteArrayInputStream (rawData)),
null,
__debug
);
} catch (DiSLREServerException e){}
}
/**
......@@ -95,8 +94,10 @@ public class SHVM implements ISHVM {
* @param loaderTag Unique identifier of the class loader in context of single VM.
* @param superClassTag Unique identifier of super class in context of single VM.
*/
@Override public void HandleClassInfo (
long tag, String signature, String generic, long loaderTag, long superClassTag)
@Override
public void HandleClassInfo (
long tag, String signature, String generic, long loaderTag, long superClassTag
)
{
__shvmContext
.getShadowClassTable ()
......@@ -107,6 +108,9 @@ public class SHVM implements ISHVM {
public void HandleClose ()
{
// Wait for all executors to complete run of the analysis invocation
__anlHndl.exit ();
// invoke atExit on all analyses
for (final RemoteAnalysis analysis : __shvmContext.getAnalysisResolver ().getAllAnalyses ()) {
try {
......@@ -156,19 +160,14 @@ public class SHVM implements ISHVM {
* @param descriptor Descriptor of method. I.e. its signature.
*/
@Override
public void HandleRegisterAnalysis (int analysisID, String descriptor)
public void HandleRegisterAnalysis (int analysisID, String descriptor) throws DiSLREServerException
{
try {
__shvmContext
__shvmContext
.getAnalysisResolver ()
.registerMethodId ((short)analysisID, descriptor);
__log.debug ("DiSL-RE: registered %s as analysis method %d\n", descriptor, analysisID);
} catch (DiSLREServerException e) {
}
}
......
......@@ -32,7 +32,7 @@ public interface ISHVM {
*
* @param rawData Packed raw data
*/
void HandleAnalyze(byte[] rawData);
void HandleAnalyze(byte[] rawData) throws DiSLREServerException;
/**
* Handle the message about closing the connection and end of the analysis.
......@@ -61,7 +61,7 @@ public interface ISHVM {
* @param analysisID Id of the analysis method.
* @param descriptor Descriptor of method. I.e. its signature.
*/
void HandleRegisterAnalysis(int analysisID, String descriptor);
void HandleRegisterAnalysis(int analysisID, String descriptor) throws DiSLREServerException;
/**
* Change the value of the string specified by the tag.
......
......@@ -109,13 +109,13 @@ sender_loop (void * arg)
switch (pb->analysis_buff->bytes[0])
{
case MSG_ANALYZE:
printf("Attempting to repack analysis\n");
ldebug("Attempting to repack analysis\n");
buffer_repack_analysis(pb->analysis_buff, &temp_buffer);
send_data(sockfd, &temp_buffer);
buffer_clear(&temp_buffer);
break;
case MSG_OBJ_FREE:
printf("Attempting to repack objfree\n");
ldebug("Attempting to repack objfree\n");
buffer_repack_objfree(pb->analysis_buff, &temp_buffer);
send_data(sockfd, &temp_buffer);
buffer_clear(&temp_buffer);
......
......@@ -142,8 +142,11 @@ buffer_append_agentmessage(buffer_t * restrict buffer, const AgentMessage * msg)
void
buffer_repack_analysis(buffer_t * restrict source, buffer_t * destination)
{
if(buffer_length(source) <= 0)
return;
// Shift by raw data header. See messager_analyze_header()
uint8_t shift = sizeof (uint8_t) + sizeof (jlong) + sizeof (jint);
uint8_t shift = sizeof (uint8_t);
Analyze analyze = ANALYZE__INIT;
analyze.rawdata.len = source->position - shift;
......
......@@ -30,25 +30,17 @@ void buffer_destroy (buffer_t * restrict buffer);
uint8_t *
buffer_claim (buffer_t * restrict buffer, const size_t size);
/*
* These methods are marked as inline, but in semantics of C99 this doesnt mean
* that they are inlined during compilation. While debugging with DEBUG:=1
* these symols will be marked as unreachable. Fix it by marking them static
* inline.
*
* TODO: Consider removing the inline modifier.
*/
inline size_t
static inline size_t
buffer_position (const buffer_t * restrict buffer) {
return buffer->position;
}
inline size_t
static inline size_t
buffer_length (const buffer_t * restrict buffer) {
return buffer->position;
}
inline void
static inline void
buffer_clear (buffer_t * restrict buffer) {
buffer->position = 0;
}
......
Markdown is supported
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