Add coredump feature and print PC
This commit is contained in:
@@ -16,6 +16,12 @@ msgstr "SmartDNS是一个本地高性能DNS服务器,支持避免域名污染
|
|||||||
msgid "Custom Settings"
|
msgid "Custom Settings"
|
||||||
msgstr "自定义设置"
|
msgstr "自定义设置"
|
||||||
|
|
||||||
|
msgid "Generate Coredump"
|
||||||
|
msgstr "生成coredump"
|
||||||
|
|
||||||
|
msgid "Generate Coredump file when smartdns crash, coredump file is located at /tmp/smartdns.xxx.core."
|
||||||
|
msgstr "当smartdns异常时生成coredump文件,coredump文件在/tmp/smartdns.xxx.core."
|
||||||
|
|
||||||
msgid "Server Name"
|
msgid "Server Name"
|
||||||
msgstr "服务器名称"
|
msgstr "服务器名称"
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,13 @@ function custom.write(self, section, value)
|
|||||||
nixio.fs.writefile("/etc/smartdns/custom.conf", value)
|
nixio.fs.writefile("/etc/smartdns/custom.conf", value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
o = s:taboption("custom", Flag, "coredump", translate("Generate Coredump"), translate("Generate Coredump file when smartdns crash, coredump file is located at /tmp/smartdns.xxx.core."))
|
||||||
|
o.rmempty = false
|
||||||
|
o.default = o.disabled
|
||||||
|
o.cfgvalue = function(...)
|
||||||
|
return Flag.cfgvalue(...) or "0"
|
||||||
|
end
|
||||||
|
|
||||||
-- Upstream servers
|
-- Upstream servers
|
||||||
s = m:section(TypedSection, "server", translate("Upstream Servers"), translate("Upstream Servers, support UDP, TCP protocol. " ..
|
s = m:section(TypedSection, "server", translate("Upstream Servers"), translate("Upstream Servers, support UDP, TCP protocol. " ..
|
||||||
"Please configure multiple DNS servers, including multiple foreign DNS servers."))
|
"Please configure multiple DNS servers, including multiple foreign DNS servers."))
|
||||||
|
|||||||
@@ -174,6 +174,11 @@ start_service() {
|
|||||||
conf_append "server-name" "$server_name"
|
conf_append "server-name" "$server_name"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
config_get "coredump" "$section" "coredump" "0"
|
||||||
|
if [ "$coredump" = "1" ]; then
|
||||||
|
COREDUMP="1"
|
||||||
|
fi
|
||||||
|
|
||||||
config_get "port" "$section" "port" "6053"
|
config_get "port" "$section" "port" "6053"
|
||||||
config_get "ipv6_server" "$section" "ipv6_server" "1"
|
config_get "ipv6_server" "$section" "ipv6_server" "1"
|
||||||
config_get "tcp_server" "$section" "tcp_server" "1"
|
config_get "tcp_server" "$section" "tcp_server" "1"
|
||||||
|
|||||||
@@ -927,7 +927,7 @@ static int _dns_client_process_udp(struct dns_server_info *server_info, struct e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tlog(TLOG_DEBUG, "recv udp, from %s, ttl: %d", gethost_by_addr(from_host, (struct sockaddr *)&from, from_len), ttl);
|
tlog(TLOG_DEBUG, "recv udp, from %s, len: %d, ttl: %d", gethost_by_addr(from_host, (struct sockaddr *)&from, from_len), len, ttl);
|
||||||
|
|
||||||
if ((ttl != server_info->ttl) && (server_info->ttl > 0) && (server_info->result_flag & DNSSERVER_FLAG_CHECK_TTL)) {
|
if ((ttl != server_info->ttl) && (server_info->ttl > 0) && (server_info->result_flag & DNSSERVER_FLAG_CHECK_TTL)) {
|
||||||
/* tlog(TLOG_DEBUG, "TTL mismatch, from:%d, local %d, discard result", ttl, server_info->ttl); */
|
/* tlog(TLOG_DEBUG, "TTL mismatch, from:%d, local %d, discard result", ttl, server_info->ttl); */
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <ucontext.h>
|
||||||
|
|
||||||
#define RESOLVE_FILE "/etc/resolv.conf"
|
#define RESOLVE_FILE "/etc/resolv.conf"
|
||||||
#define MAX_LINE_LEN 1024
|
#define MAX_LINE_LEN 1024
|
||||||
@@ -297,10 +298,24 @@ void sig_exit(int signo)
|
|||||||
dns_server_stop();
|
dns_server_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sig_error_exit(int signo, siginfo_t *siginfo, void *context)
|
void sig_error_exit(int signo, siginfo_t *siginfo, void *ct)
|
||||||
{
|
{
|
||||||
tlog(TLOG_ERROR, "process exit with signal %d, code = %d, errno = %d, pid = %d, self = %d, addr = %p\n", signo, siginfo->si_code, siginfo->si_errno,
|
unsigned long PC = 0;
|
||||||
siginfo->si_pid, getpid(), siginfo->si_addr);
|
ucontext_t *context = ct;
|
||||||
|
#if defined(__i386__)
|
||||||
|
int *pgregs = (int*)(&(context->uc_mcontext.gregs));
|
||||||
|
PC = pgregs[REG_EIP];
|
||||||
|
#elif defined(__x86_64__)
|
||||||
|
int *pgregs = (int*)(&(context->uc_mcontext.gregs));
|
||||||
|
PC = pgregs[REG_RIP];
|
||||||
|
#elif defined(__aarch64__) || defined(__arm__)
|
||||||
|
PC = context->uc_mcontext.arm_pc;
|
||||||
|
#elif defined(__mips__)
|
||||||
|
PC = context->uc_mcontext.pc;
|
||||||
|
#endif
|
||||||
|
tlog(TLOG_ERROR, "process exit with signal %d, code = %d, errno = %d, pid = %d, self = %d, pc = %#lx, addr = %#lx\n", signo, siginfo->si_code, siginfo->si_errno,
|
||||||
|
siginfo->si_pid, getpid(), PC, (unsigned long)siginfo->si_addr);
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user