functor vs lamba

Demonstrated by std::sort
Comparing to function pointers, lambda can access all variables in enclosing scope.
Comparing to function pointers, functor have state, with help from data members in the functor class.

bool MyCompare(const int& a, const int& b)
	return a > b;

class MyComparer
	MyComparer(bool bCompareByAbsValue)
		mbCompareByAbsValue = bCompareByAbsValue;
	bool operator()(const int& a, const int& b)
		if (mbCompareByAbsValue)
			return abs(a) > abs(b);
			return a > b;
	bool mbCompareByAbsValue;
void output(string by, int * aInt, size_t nLen)
	cout << "sort by " << by << " descending order: " << endl;
	for (int i = 0; i < nLen; i++)
		cout << aInt[i] << " ";
	cout << endl;

void TestFunctionPtrFunctorLambda()
	const int LENGTH = 3;
	int nLen = LENGTH;
	int aInt[LENGTH] = {2, -3, 1};
	int * pInt = aInt;
	std::sort(pInt, pInt + nLen, MyCompare);
	output("function pointer", aInt, nLen);

	bool bCompareByAbsValue = true;
	std::sort(pInt, pInt + nLen,
		[bCompareByAbsValue](int a, int b) {
		if (bCompareByAbsValue)
			return abs(a) > abs(b);
			return a > b;
	output("lambda, absolute value", aInt, nLen);

	std::sort(pInt, pInt + nLen, MyComparer(bCompareByAbsValue));
	output("functor, absolute value", aInt, nLen);

sort by function pointer descending order:
2 1 -3
sort by lambda, absolute value descending order:
-3 2 1
sort by functor, absolute value descending order:
-3 2 1


gdb for embedded device

Using gdb to debug this streaming device: MStar MSO9380 ARM Cortex-A53
On device, by telnet:
# wdog 0 # turn off watch dog
# gdbserver :5555 –attach $PROCESS_ID_MYAPP # part of debug build of rootfs

On host: Linux desktop:
$ arm-linux-gdb $FILE_FULLPATH_MYAPP # the file of PROCESS_ID_MYAPP with symbols

Inside (gdb):
set pagination off # reduce output
set print pretty on # print with indentation
set sysroot /mypath/rootfs #location of .so files, alias of solib-absolute-prefix
set solib-search-path /mypath/rootfs1:/mypath/rootfs2
target remote #connect to gdbserver
b My.cpp:57 #break at line 57
c #continue to run

Minimum Ad server

Here is a Minimum Ad server that serves pre-roll ad to Roku player.

This server is just a web server which hosts three items:
1. the VMAP:
2. the VAST:
3. the ad .mp4 file:

The video content, some gym training, is hosted here:
Here is the screen recording that this ad plays on Roku Ultra.

The demo channel source code that plays this ad can be found at,
which is based on Nas’s RAF demo.

breakpad in Uverse

I integrated breakpad into AT&T U-verse STB crash logging system starting 2015.
breakpad is google’s open-source multiplatform crash reporting system.
1. smaller dump file. The core dump is usually hundreds of MB, hundred times larger than breakpad dump, or mini dump.
2. its minidump file follows Windows MiniDump MDMP format, standard format generating call stack for all threads.
cons: in-process reporting, but fixed by Crashpad, out-of-process reporting

1. Establish a way to link to breakpad library and run init:
This can be done without touching the main application binary file, which is named TV2MonoClient.
start application: LD_PRELOAD=/mnt/ TV2MonoClient
we hood up breakpad with TV2MonoClient in DllMain() of
2. tell TV2MonoClient where to save the minidump upon crash in DllMain:
c++ code: new google_breakpad::ExceptionHandler(MinidumpDescriptor, NULL, dumpCallback, NULL, true, -1);
MinidumpDescriptor has the full file name of the minidump
dumpCallback is called when the dump has been created, where we can, e.g. upload the dump.
3. parse the minidump into plain text file
all the symbol files of TV2MonoClient and .so files are needed.
Parsing was done on a windows server, and the key tool is minidump_stackwalk.exe from google, like so:
minidump_stackwalk.exe minidumpfile .\appSymbolFiles >plainStackOutput.txt 2>err.txt
plainStackOutput.txt receives the call stacks.