C语言编写的代理程序怎么定位某个功能模块的源代码位置?

丶不断追寻 2014-09-10 11:31:24
如题,一个数据备份软件,有一个linux下的代理模块,windows下主控端运行之后,备份Linux下数据的时候,数据统计模块不好使,怎么定位这个功能模块的源代码位置?
...全文
297 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
丶不断追寻 2014-09-11
  • 打赏
  • 举报
回复
差不多解决了,非常感谢各位
版主大哥 2014-09-10
  • 打赏
  • 举报
回复
上图
丶不断追寻 2014-09-10
  • 打赏
  • 举报
回复
引用 4 楼 xihu1364 的回复:
应该在 windows主控端,搜搜 stat关键字 一般在收消息的地方,看看统计之类的变量 然后全文搜...
但是windows下代理没问题啊,这就应该不是主控端的事了吧?
丶不断追寻 2014-09-10
  • 打赏
  • 举报
回复
就比如说吧,本来是备份100M的东西,结果备完之后上面只显示1M,数据大小不对
版主大哥 2014-09-10
  • 打赏
  • 举报
回复
应该在 windows主控端,搜搜 stat关键字 一般在收消息的地方,看看统计之类的变量 然后全文搜...
丶不断追寻 2014-09-10
  • 打赏
  • 举报
回复
引用 2 楼 xihu1364 的回复:
楼主描述很不清楚啊 数据统计?统计备份文件的收发大小?
是啊,就是那个东西,哎,没有经验,不知道从何下手
版主大哥 2014-09-10
  • 打赏
  • 举报
回复
楼主描述很不清楚啊 数据统计?统计备份文件的收发大小?
丶不断追寻 2014-09-10
  • 打赏
  • 举报
回复
自己顶一下,求大神帮忙啊!!!
707wk 2014-09-10
  • 打赏
  • 举报
回复
引用 9 楼 mujiok2003 的回复:
gdb调试调试, 看看业务流程。
+1,我真不知道
mujiok2003 2014-09-10
  • 打赏
  • 举报
回复
gdb调试调试, 看看业务流程。
赵4老师 2014-09-10
  • 打赏
  • 举报
回复
有时不将“调用函数名字+各参数值,进入函数后各参数值,中间变量值,退出函数前准备返回的值,返回函数到调用处后函数名字+各参数值+返回值”这些信息写日志到文件中是无论如何也发现不了问题在哪里的,包括捕获各种异常、写日志到屏幕、单步或设断点或生成core文件、……这些方法都不行! 写日志到文件参考下面:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
    #include <windows.h>
    #include <io.h>
#else
    #include <unistd.h>
    #include <sys/time.h>
    #include <pthread.h>
    #define  CRITICAL_SECTION   pthread_mutex_t
    #define  _vsnprintf         vsnprintf
#endif
//Log{
#define MAXLOGSIZE 20000000
#define MAXLINSIZE 16000
#include <time.h>
#include <sys/timeb.h>
#include <stdarg.h>
char logfilename1[]="MyLog1.log";
char logfilename2[]="MyLog2.log";
static char logstr[MAXLINSIZE+1];
char datestr[16];
char timestr[16];
char mss[4];
CRITICAL_SECTION cs_log;
FILE *flog;
#ifdef WIN32
void Lock(CRITICAL_SECTION *l) {
    EnterCriticalSection(l);
}
void Unlock(CRITICAL_SECTION *l) {
    LeaveCriticalSection(l);
}
#else
void Lock(CRITICAL_SECTION *l) {
    pthread_mutex_lock(l);
}
void Unlock(CRITICAL_SECTION *l) {
    pthread_mutex_unlock(l);
}
#endif
void LogV(const char *pszFmt,va_list argp) {
    struct tm *now;
    struct timeb tb;

    if (NULL==pszFmt||0==pszFmt[0]) return;
    _vsnprintf(logstr,MAXLINSIZE,pszFmt,argp);
    ftime(&tb);
    now=localtime(&tb.time);
    sprintf(datestr,"%04d-%02d-%02d",now->tm_year+1900,now->tm_mon+1,now->tm_mday);
    sprintf(timestr,"%02d:%02d:%02d",now->tm_hour     ,now->tm_min  ,now->tm_sec );
    sprintf(mss,"%03d",tb.millitm);
    printf("%s %s.%s %s",datestr,timestr,mss,logstr);
    flog=fopen(logfilename1,"a");
    if (NULL!=flog) {
        fprintf(flog,"%s %s.%s %s",datestr,timestr,mss,logstr);
        if (ftell(flog)>MAXLOGSIZE) {
            fclose(flog);
            if (rename(logfilename1,logfilename2)) {
                remove(logfilename2);
                rename(logfilename1,logfilename2);
            }
        } else {
            fclose(flog);
        }
    }
}
void Log(const char *pszFmt,...) {
    va_list argp;

    Lock(&cs_log);
    va_start(argp,pszFmt);
    LogV(pszFmt,argp);
    va_end(argp);
    Unlock(&cs_log);
}
//Log}
int main(int argc,char * argv[]) {
    int i;
#ifdef WIN32
    InitializeCriticalSection(&cs_log);
#else
    pthread_mutex_init(&cs_log,NULL);
#endif
    for (i=0;i<10000;i++) {
        Log("This is a Log %04d from FILE:%s LINE:%d\n",i, __FILE__, __LINE__);
    }
#ifdef WIN32
    DeleteCriticalSection(&cs_log);
#else
    pthread_mutex_destroy(&cs_log);
#endif
    return 0;
}
//1-78行添加到你带main的.c或.cpp的那个文件的最前面
//81-85行添加到你的main函数开头
//89-93行添加到你的main函数结束前
//在要写LOG的地方仿照第87行的写法写LOG到文件MyLog1.log中

69,377

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧