解决了我一个大问题!!!

http://stackoverflow.com/questions/5048112/use-gdb-to-debug-a-c-program-called-from-a-shell-script

There are two options that you can do:

1) invoke GDB directly within the shell script. This would imply that you don't have standard in and standard out redirected.

2) run the shell script and then attach the debugger to the already running c++ process like so: gdb progname 1234 where 1234 is the process ID of the running c++ process.

If you need to do things before the program starts running then option 1 would be the better choice, otherwise option 2 is the cleaner way.

if test -f $ASHA_HOME/bin/hasocket; then
#exec $ASHA_HOME/bin/hasocket $PRODUCT_HOME/bin/$EXE $*
echo "$PRODUCT_HOME/bin/$EXE $*"
gdb "$PRODUCT_HOME/bin/$EXE"
else
#exec $PRODUCT_HOME/bin/$EXE $*
echo "$PRODUCT_HOME/bin/$EXE $*"
gdb $PRODUCT_HOME/bin/$EXE
fi

Use GDB to debug a C++ program called from a shell script的更多相关文章

  1. shell script 的追踪与 debug

    shell script 的追踪与 debug scripts 在运行之前,最怕的就是出现语法错误的问题了!那么我们如何 debug 呢?有没有办法不需要透过直接运行该 scripts 就可以来判断是 ...

  2. using gdb to debug c program

    #include <stdio.h> static void display(int i, int *ptr); int main(void) { int x = 5; int *xptr ...

  3. gdb/valgrind/coredump to debug c/cpp program

    gdb/valgrind/coredump 调试 1.gdb 调试 while/for 循环 ①如果在调试 while/for的时候,可以用until xxx(其中,xxx代表 行号)直接跳转到循环后 ...

  4. The Better Way to Debug Your JavaScript Program

    Debugging JS program is not as easy as we do in Visual Studio or any other IDE. I usually us "a ...

  5. gdb远程debug A syntax error in expression, near `variable)'.

    今天调试有个linux环境的应用时,gdb提示A syntax error in expression, near `variable)'.,最后经查,gdb版本过低(比如7.2)或者源代码不匹配所致 ...

  6. Using DTrace to Profile and Debug A C++ Program

    http://www.oracle.com/technetwork/server-storage/solaris/dtrace-cc-138561.html

  7. Shell Script - 追踪与debug

    [root@www ~]# sh [-nvx] scripts.sh 选项与参数: -n :不要运行 script,仅查询语法的问题: -v :再运行 sccript 前,先将 scripts 的内容 ...

  8. sublime使用

    显示侧板的文件夹: View -> Side Bar 菜单[project]->add folder to  project.把文件夹显示在左边的sidebar上. 安装插件: packa ...

  9. 学习shell script

    摘要:概述.script的编写.test命令.[]判断符号.默认变量($1...).if...then条件判断式. 一.概述 [什么是shell script] 针对shell所写的脚本,将多个命令汇 ...

随机推荐

  1. metasploit(MSF)对windows的ms17-010漏洞利用

    picture 配置exploit msf > use exploit/windows/smb/ms17_010_eternalblue msf exploit(windows/smb/ms17 ...

  2. 《C Elements of Style》 书摘

    <C Elements of Style> 书摘 学完C语言和数据结构后,虽然能解决一些问题,但总觉得自己写的程序丑陋,不专业.这时候看到了Steve Oualline写的<C El ...

  3. vector.resize 与 vector.reserve的区别(转载)

    转载:https://blog.csdn.net/shuilan0066/article/details/3588478 reserve是容器预留空间,但并不真正创建元素对象,在创建对象之前,不能引用 ...

  4. Junit的套件使用

    定义一个类,在类的上方添加@RunWith(Suite.class)和@SuiteClasses({XX.class,YY.class,...}) 实例有两个类分别为:public class Log ...

  5. 【POJ1509】Glass Beads

    [POJ1509]Glass Beads [题目描述]给定字符串S,并规定首尾相连成环,求出最小字典序. [输入]输入有多个数据,第一行只包括正整数N,表示有N组数据.每个数据包括一行,输入该字符串. ...

  6. POJ - 1287 Networking 【最小生成树Kruskal】

    Networking Description You are assigned to design network connections between certain points in a wi ...

  7. P3211 [HNOI2011]XOR和路径

    思路 看到异或,容易联想到二进制位之间是相互独立的,所以可以把问题变成每个二进制位为1的概率再乘上(1<<pos)的值 假设现在考虑到pos位,设f[i]为第i个节点期望的异或和第pos位 ...

  8. 取消开机logo,改成代码刷屏

    将开机logo改成开始时代码刷屏,这样就能很方便看到开始时的一些问题 首先 sudo chmod 666 /etc/default/grub 然后将 GRUB_CMDLINE_LINUX_DEFAUL ...

  9. Bytom移动端钱包SDK开发基础

    比原项目仓库: Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchain/bytom Byto ...

  10. 剥开比原看代码12:比原是如何通过/create-account-receiver创建地址的?

    作者:freewind 比原项目仓库: Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchai ...