Stream: brlcad

Topic: Odd return code issue


view this post on Zulip starseeker (Apr 19 2021 at 15:32):

I'm seeing the following - when calling ged_exec, I'm expecting to get GED_OK assigned:

ret = ged_tire(&ged, ac, (const char **)av);

Following the execution through the calls, it looks like the function should indeed be returning GED_OK (0), but ret instead ends up assigned 16:

Breakpoint 1, main (ac=2, av=0x7fffffffdff8) at ../src/shapes/tire.c:62
62      ret = ged_tire(&ged, ac, (const char **)av);
(gdb) print ret
$1 = 0
(gdb) break ged_exec
Breakpoint 2 at 0x7ffff7f5ffd9: file ../src/libged/exec.cpp, line 40.
(gdb) c
Continuing.

Breakpoint 2, ged_exec (gedp=0x7ffff7fc8068 <cmd_map+8>, argc=21845, argv=0x7fffffffe32d) at ../src/libged/exec.cpp:40
40  {
(gdb) n
41      if (!gedp || !argc || !argv) {
(gdb)
45      double start = 0.0;
(gdb)
46      const char *tstr = getenv("GED_EXEC_TIME");
(gdb)
47      if (tstr) {
(gdb)
59      std::map<std::string, const struct ged_cmd *> *cmap = (std::map<std::string, const struct ged_cmd *> *)ged_cmds;
(gdb)
68      if (!cmap->size()) {
(gdb)
72      std::map<std::string, const struct ged_cmd *>::iterator c_it = cmap->find(std::string(argv[0]));
(gdb)
73      if (c_it == cmap->end()) {
(gdb)
78      const struct ged_cmd *cmd = c_it->second;
(gdb)
83      int cret = (*cmd->i->cmd)(gedp, argc, argv);
(gdb)
85      if (tstr) {
(gdb) print cret
$2 = 0
(gdb) n
89      return cret;
(gdb) print cret
$3 = 0
(gdb) n
90  }
(gdb)
main (ac=2, av=0x7fffffffdff8) at ../src/shapes/tire.c:65
65      wdb_close(db_fp);
(gdb) print ret
$4 = 16
(gdb)

view this post on Zulip starseeker (Apr 19 2021 at 15:42):

Ah, was feeding in argv[0] binary path instead of GED command to ged_exec - that'll do it.


Last updated: Oct 09 2024 at 00:44 UTC