AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

How can I use gdb to check segmentation fault?
 
 

Can someone kindly tell me how I can use gdb to test chatscript?

I’m getting seg fault when I try to get the length of ^jsonopen() result.

Thanks!

 

 
  [ # 1 ]

1. stand in SRC directory and do “make debugserver”
2. stand in BINARIES directory and do “gdb ChatScriptDebug”
3. in gdb do “set args local”  (presuming that will get you the crash
4. in gdb do “run”
execute til you crash
5. do in gdb backtrace and see what file/line number it complains about. If you can get the values of any variable there by doing “print xxx” where that is a useful variable name

 

 
  [ # 2 ]

Thanks a lot!

 

 
  [ # 3 ]

Hi Bruce,

It seems the command you wrote above won’t compile for Mac. Seems some libs are missing.

undefined symbols for architecture x86_64:
  
"_curl_easy_cleanup"referenced from:
      
UrlEncode(char*) in json.o
      JSONOpenCode
(char*) in json.o
  
"_curl_easy_escape"referenced from:
      
UrlEncode(char*) in json.o
  
"_curl_easy_getinfo"referenced from:
      
JSONOpenCode(char*) in json.o
  
"_curl_easy_init"referenced from:
      
UrlEncode(char*) in json.o
      JSONOpenCode
(char*) in json.o
  
"_curl_easy_perform"referenced from:
      
JSONOpenCode(char*) in json.o
  
"_curl_easy_setopt"referenced from:
      
JSONOpenCode(char*) in json.o
  
"_curl_free"referenced from:
      
UrlEncode(char*) in json.o
  
"_curl_global_cleanup"referenced from:
      
CurlShutdown() in json.o
  
"_curl_global_init"referenced from:
      
InitCurl() in json.o
  
"_curl_slist_append"referenced from:
      
JSONOpenCode(char*) in json.o
  
"_curl_slist_free_all"referenced from:
      
JSONOpenCode(char*) in json.o
ld
symbol(snot found for architecture x86_64 
 

 
  [ # 4 ]

Solved it.

I have to add -lcurl to the compile command, since curl library is needed on Mac.

Also, I have to do a sudo when running gdb. Some permission issues.

Hope it helps whoever encounter similar problems.

 

 
  login or register to react