我使用gdb来调试我的cpp代码.我用这种方式设置断点:
(gdb) break ParseDriver.cc:60
No source file named ParseDriver.cc.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (ParseDriver.cc:60) pending.
Run Code Online (Sandbox Code Playgroud)
为了简化设置断点,我编写了一个简单的gdb脚本(名为breakpoints.gdb),它只包含一行:
break ParseDriver.cc:60
Run Code Online (Sandbox Code Playgroud)
我在gdb终端中获取此脚本,但它失败了.
(gdb) source ~/breakpoints.gdb
No source file named ParseDriver.cc.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Run Code Online (Sandbox Code Playgroud)
似乎我们需要在脚本中回答Y以设置断点.
那么,我如何在gdb脚本中回答Y?先感谢您.
我想知道如何确定脚本文件是执行还是源.
例如,
# Shell script filename build.sh
if [ "x$0" = "xbash" ]; then
echo "I am sourced by Bash"
else
echo "I am executed by Bash"
fi
Run Code Online (Sandbox Code Playgroud)
如果我输入
source build.sh
Run Code Online (Sandbox Code Playgroud)
它将输出我来自Bash.
如果我输入
./build.sh
Run Code Online (Sandbox Code Playgroud)
它会输出我由Bash执行.
目前,我使用$ 0来做到这一点.有更好的主意吗?
在Tripeee的启发下,我找到了一个更好的方法:
#!/bin/bash
if [ "x$(awk -F/ '{print $NF}' <<< $0)" = 'xcdruntime' ]; then
echo Try to source me, not execute me.
else
cd /opt/www/app/pepsi/protected/runtime
fi
Run Code Online (Sandbox Code Playgroud) 在wiki的设置中,我们可以设置wiki的起始页面.
呃,我的问题是如何使"按标题索引"成为起始页?

我尝试编写示例代码来组合akka和actor.但是在编译代码时我收到了错误消息.
代码非常简单,如下所示.
那么,我有什么问题?
[error] /home/qos/workspaces/actors/actors.scala:20: type mismatch;
[error] found : Unit
[error] required: scala.sys.process.ProcessLogger
[error] execute(cmd)
[error] ^
[error] one error found
[error] (compile:compile) Compilation failed
Run Code Online (Sandbox Code Playgroud)
代码是
import scala.sys.process._
import akka.actor._
object TryActor {
def main(args: Array[String]) {
val akkaSystem = ActorSystem("akkaSystem")
val worker = akkaSystem.actorOf(Props[Worker], name = "work0")
worker ! Command("ls")
}
case class Command(cmd: String)
class Worker extends Actor {
def receive = {
case Command(cmd) => {
println(cmd)
"echo recieve message from someone" !
execute(cmd.toString)
}
} …Run Code Online (Sandbox Code Playgroud)