summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/bp_sim.h6
-rwxr-xr-xsrc/common/basic_utils.cpp38
-rwxr-xr-xsrc/common/basic_utils.h10
-rw-r--r--src/main_dpdk.cpp24
4 files changed, 76 insertions, 2 deletions
diff --git a/src/bp_sim.h b/src/bp_sim.h
index 1f35faba..42ea2178 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -679,7 +679,13 @@ public:
return (btGetMaskBit32(m_flags1,6,6) ? true:false);
}
+ void setCoreDumpEnable(bool enable) {
+ btSetMaskBit32(m_flags1, 7, 7, (enable ? 1 : 0) );
+ }
+ bool getCoreDumpEnable(){
+ return (btGetMaskBit32(m_flags1, 7, 7) ? true : false);
+ }
public:
void Dump(FILE *fd);
diff --git a/src/common/basic_utils.cpp b/src/common/basic_utils.cpp
index 4f5578a6..b2277697 100755
--- a/src/common/basic_utils.cpp
+++ b/src/common/basic_utils.cpp
@@ -18,6 +18,7 @@ limitations under the License.
#include <stdio.h>
#include <string>
#include <sstream>
+#include <sys/resource.h>
bool utl_is_file_exists (const std::string& name) {
if (FILE *file = fopen(name.c_str(), "r")) {
@@ -198,3 +199,40 @@ utl_generate_random_str(unsigned int &seed, int len) {
return (ss.str());
}
+/**
+ * define the coredump size
+ * allowed when crashing
+ *
+ * @param size - -1 means unlimited
+ * @param map_huge_pages - should the core map the huge TLB
+ * pages
+ */
+void utl_set_coredump_size(long size, bool map_huge_pages) {
+ int mask;
+ struct rlimit core_limits;
+
+ if (size == -1) {
+ core_limits.rlim_cur = core_limits.rlim_max = RLIM_INFINITY;
+ } else {
+ core_limits.rlim_cur = core_limits.rlim_max = size;
+ }
+
+ setrlimit(RLIMIT_CORE, &core_limits);
+
+ /* set core dump mask */
+ FILE *fp = fopen("/proc/self/coredump_filter", "wb");
+ if (!fp) {
+ printf("failed to open /proc/self/coredump_filter\n");
+ exit(-1);
+ }
+
+ /* huge pages is the 5th bit */
+ if (map_huge_pages) {
+ mask = 0x33;
+ } else {
+ mask = 0x13;
+ }
+
+ fprintf(fp, "%08x\n", mask);
+ fclose(fp);
+}
diff --git a/src/common/basic_utils.h b/src/common/basic_utils.h
index 63e858ab..1884e896 100755
--- a/src/common/basic_utils.h
+++ b/src/common/basic_utils.h
@@ -87,6 +87,16 @@ void utl_macaddr_to_str(const uint8_t *macaddr, std::string &output);
std::string utl_generate_random_str(unsigned int &seed, int len);
+/**
+ * define the coredump size
+ * allowed when crashing
+ *
+ * @param size - -1 means unlimited
+ * @param map_huge_pages - should the core map the huge TLB
+ * pages
+ */
+void utl_set_coredump_size(long size, bool map_huge_pages = false);
+
#endif
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index dcef2f38..4f8d8937 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -50,6 +50,7 @@
#include <rte_mbuf.h>
#include <rte_random.h>
#include <rte_version.h>
+
#include "bp_sim.h"
#include "os_time.h"
#include "common/arg/SimpleGlob.h"
@@ -553,7 +554,9 @@ enum { OPT_HELP,
OPT_PREFIX,
OPT_MAC_SPLIT,
OPT_SEND_DEBUG_PKT,
- OPT_NO_WATCHDOG
+ OPT_NO_WATCHDOG,
+ OPT_ALLOW_COREDUMP
+
};
@@ -615,7 +618,8 @@ static CSimpleOpt::SOption parser_options[] =
{ OPT_MAC_SPLIT, "--mac-spread", SO_REQ_SEP },
{ OPT_SEND_DEBUG_PKT, "--send-debug-pkt", SO_REQ_SEP },
{ OPT_MBUF_FACTOR , "--mbuf-factor", SO_REQ_SEP },
- { OPT_NO_WATCHDOG , "--no-watchdog", SO_NONE },
+ { OPT_NO_WATCHDOG , "--no-watchdog", SO_NONE },
+ { OPT_ALLOW_COREDUMP , "--allow-coredump", SO_NONE },
SO_END_OF_OPTIONS
@@ -718,6 +722,8 @@ static int usage(){
printf(" \n");
printf(" --no-watchdog : disable watchdog \n");
printf(" \n");
+ printf(" --allow-coredump : allow a creation of core dump \n");
+ printf(" \n");
printf(" --vm-sim : simulate vm with driver of one input queue and one output queue \n");
printf(" \n");
printf(" Examples: ");
@@ -935,6 +941,10 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t
po->preview.setWDDisable(true);
break;
+ case OPT_ALLOW_COREDUMP :
+ po->preview.setCoreDumpEnable(true);
+ break;
+
case OPT_LATENCY_PREVIEW :
sscanf(args.OptionArg(),"%d", &po->m_latency_prev);
break;
@@ -4703,6 +4713,15 @@ int main_test(int argc , char * argv[]){
exit(-1);
}
+ /* enable core dump if requested */
+ if (CGlobalInfo::m_options.preview.getCoreDumpEnable()) {
+ utl_set_coredump_size(-1);
+ }
+ else {
+ utl_set_coredump_size(0);
+ }
+
+
update_global_info_from_platform_file();
/* It is not a mistake. Give the user higher priorty over the configuration file */
@@ -5779,3 +5798,4 @@ int TrexDpdkPlatformApi::get_active_pgids(flow_stat_active_t &result) const {
CFlowStatParser *TrexDpdkPlatformApi::get_flow_stat_parser() const {
return CTRexExtendedDriverDb::Ins()->get_drv()->get_flow_stat_parser();
}
+