Skip to content
This repository was archived by the owner on Aug 27, 2025. It is now read-only.

Conversation

RushOnline
Copy link

without this patch call to backtrace(3) returns zero.

Tested on RPiZ without analog/digital gain control support in ThreadX API:

Output of modified raspistill -o /dev/null -awb off -awbg 1.56,1.78 -ex off -ag 1 -dg 1 -t 1 -v before and after patch:

-Obtained 0 stack frames.
+Obtained 7 stack frames.
+./raspistill(print_trace+0x1c) [0x11bcc]
+./raspistill(mmal_status_to_int+0x30) [0x12184]
+./raspistill(raspicamcontrol_set_gains+0x88) [0x1048c]
+./raspistill(raspicamcontrol_set_all_parameters+0x39c) [0xeef8]
+./raspistill() [0x1561c]
+./raspistill(main+0x228) [0x1798c]
+/lib/arm-linux-gnueabihf/libc.so.6(__libc_start_main+0x114) [0xb6c18678]
mmal: Function not implemented

raspistill modification (just for test, not included in this pull request):

diff --git a/host_applications/linux/apps/raspicam/RaspiHelpers.c b/host_applications/linux/apps/raspicam/RaspiHelpers.c
index 5c25e18..86e113e 100644
--- a/host_applications/linux/apps/raspicam/RaspiHelpers.c
+++ b/host_applications/linux/apps/raspicam/RaspiHelpers.c
@@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <unistd.h>
 #include <stdint.h>
 
+#include <execinfo.h>
 
 #include "interface/vcos/vcos.h"
 #include "interface/mmal/mmal.h"
@@ -58,6 +59,25 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 static const char *app_name;
 
+/* Obtain a backtrace and print it to stdout. */
+void print_trace (void)
+{
+  void *array[10];
+  size_t size;
+  char **strings;
+  size_t i;
+
+  size = backtrace (array, 10);
+  strings = backtrace_symbols (array, size);
+
+  printf ("Obtained %zd stack frames.\n", size);
+
+  for (i = 0; i < size; i++)
+     printf ("%s\n", strings[i]);
+
+  free (strings);
+}
+
 void print_app_details(FILE *fd)
 {
    if (!app_name)
@@ -225,6 +245,7 @@ int mmal_status_to_int(MMAL_STATUS_T status)
       return 0;
    else
    {
+         print_trace();
       switch (status)
       {
       case MMAL_ENOMEM :

@popcornmix
Copy link
Contributor

No real objections to this. @6by9 @pelwell ?

@pelwell
Copy link
Contributor

pelwell commented Dec 20, 2018

Fine by me, provided there is little overhead.

@6by9
Copy link
Contributor

6by9 commented Dec 24, 2018

It's for debug builds only, so I see little downside.
I don't know whether it needs all the debug options (-g3 vs -g), but other than library/exe size it won't do any harm, likewise -O0.

Copy link
Contributor

@luked99 luked99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps "-Og" rather than "-O0" ?

And you don't need the -funwind-tables if you have debug information around somewhere (e.g. by adding "-g").

@RushOnline
Copy link
Author

And you don't need the -funwind-tables if you have debug information around somewhere (e.g. by adding "-g").

backtrace(3) without -funwind-tables returns zero for me.

@Ruffio
Copy link

Ruffio commented May 3, 2020

@RushOnline has this been resolved?

@RushOnline
Copy link
Author

@Ruffio I don't test it since I've posted this MR. May be fresh software don't have this bug.

@Ruffio
Copy link

Ruffio commented May 3, 2020

It would be nice to get this closed, if the bug doesn't persists with fresh software

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants