Index: /branches/rel_apv_10_4_0_112_india/usr/click/lib/libdebug/debug_ftp.c
===================================================================
--- /branches/rel_apv_10_4_0_112_india/usr/click/lib/libdebug/debug_ftp.c	(revision 38037)
+++ /branches/rel_apv_10_4_0_112_india/usr/click/lib/libdebug/debug_ftp.c	(working copy)
@@ -33,6 +33,7 @@
 #include <errno.h>
 #include <click/app/proxy/proxy_errs.h>
 #include <fastlog.h>
+#include <dirent.h>
 #include "remote_debug.h"
 #include "ca_ui.h"
 #include "debug_util.h"
@@ -41,6 +42,24 @@
 #define DEBUG_FILE_PATH_LEN             512
 #define BUFF_LEN                       8192
 
+
+char *get_local_debug_file(void) {
+    DIR *dp = NULL;
+    struct dirent *dirp = NULL;
+    
+    if( (dp = opendir(ARRAY_DEBUG_BASE)) == 0) {
+	return -1;
+    }
+    while ((dirp = readdir(dp)) != 0) {
+	if(strncasecmp(dirp->d_name, SYS_DEBUG, strlen(SYS_DEBUG)) == 0 ) {
+	    closedir(dp);
+	    return (dirp->d_name);
+	}
+    }
+    closedir(dp);
+    return NULL;
+}
+
 static int
 upload_debug_file(char *user, char *strhost, char *timestamp, char *password, char *filename)
 {
@@ -52,6 +71,8 @@
 	struct stat fileinfo;
 	FILE *rp = NULL, *lp = NULL;
 	int n;
+	char *debug_ptr;
+	char localdebugfile[DEBUG_FILE_LEN];
 	
 	/*
 	 * SET the remote path where the file will be uploaded 
@@ -71,10 +92,14 @@
 	#endif
 	bzero(debug_file, DEBUG_FILE_LEN);
 	bzero(debug_file_path, DEBUG_FILE_PATH_LEN);
+	bzero(localdebugfile, DEBUG_FILE_LEN);
 
-	if(strcmp(filename,"sys_debug") == 0) {
-		snprintf(debug_file, DEBUG_FILE_LEN, "%s_%s.tar.gz", filename, timestamp);
-		snprintf(localfile, sizeof(localfile), "%s%s.tar.gz", ARRAY_DEBUG_BASE, filename);
+	if(strncmp(filename,"sys_debug", strlen("sys_debug")) == 0) {
+	    snprintf(debug_file, DEBUG_FILE_LEN, "%s_%s.tar.gz", filename, timestamp);
+	    debug_ptr = get_local_debug_file();
+	    if (debug_ptr) 
+		strcpy(localdebugfile, debug_ptr);
+	    snprintf(localfile, sizeof(localfile), "%s%s", ARRAY_DEBUG_BASE, localdebugfile);
 	} else {
 		snprintf(debug_file, DEBUG_FILE_LEN, "%s_%s.tar.gz.gpg", filename, timestamp);
 		snprintf(localfile, sizeof(localfile), "%s%s.tar.gz.gpg", ARRAY_DEBUG_BASE, filename);
@@ -156,6 +181,7 @@
 	char *password = NULL;
 	struct in_addr ipaddr;
 	char debug_file[DEBUG_FILE_LEN];
+	char *debug_ptr;
 	debug_shm_t *debug_shm = NULL;
 	int domain, ret; 
 	char buf[sizeof(struct in6_addr)];
@@ -186,20 +212,25 @@
 	} 
 
 	if(!IS_DEBUG_FILE(filename)) {
-		printf("Filename should be sys_snap,sys_log,sys_core,app_core,sys_debug,sslkeylog or all.\n");
+		printf("Filename should be sys_snap, sys_log, sys_core, app_core, sslkeylog, starts with 'sys_debug' or all.\n");
 		return -1;
 	}
 
+
 	if(strcasecmp(filename,"all") != 0) {
-		if (strcasecmp(filename,"SYS_DEBUG") == 0) {
-			snprintf(debug_file,sizeof(debug_file),ARRAY_DEBUG_FILE);
-			} else {
-			snprintf(debug_file,sizeof(debug_file),"/var/crash/%s.tar.gz.gpg",filename);
+	    if (strncasecmp(filename,"SYS_DEBUG", strlen("SYS_DEBUG")) == 0) {
+		debug_ptr = get_local_debug_file();
+		if (!debug_ptr) {
+		    printf("debug file %s doesn't exist.\n",filename);
+		    return -1;
 		}
+	    } else {
+		snprintf(debug_file,sizeof(debug_file),"/var/crash/%s.tar.gz.gpg",filename);
 		if (!file_exists(debug_file)) {
-			printf("%s doesn't exist.\n",filename);
-			return -1;
+		    printf("%s doesn't exist.\n",filename);
+		    return -1;
 		}
+	    }
 	}
 
 	printf("%s's password: ", user);
Index: /branches/rel_apv_10_4_0_112_india/usr/click/lib/libdebug/remote_debug.h
===================================================================
--- /branches/rel_apv_10_4_0_112_india/usr/click/lib/libdebug/remote_debug.h	(revision 38037)
+++ /branches/rel_apv_10_4_0_112_india/usr/click/lib/libdebug/remote_debug.h	(working copy)
@@ -87,7 +87,7 @@
 		(strcasecmp(filename,SYS_CORE) == 0)  || \
 		(strcasecmp(filename,APP_CORE) == 0) || \
 		(strcasecmp(filename,"all") == 0) || \
-		(strcasecmp(filename,SYS_DEBUG) == 0) || \
+		(strncasecmp(filename,SYS_DEBUG,strlen(SYS_DEBUG)) == 0) || \
 		(strcasecmp(filename,SSL_KEY_LOG) == 0))
 
 #define MIN_CAP 0.4  /* % of filesystem left before stop data collection */
