- 博客(39)
- 收藏
- 关注
原创 未知格式怎末分离stream
(ffmpeg -i xxx.ts -map 0:a:0 -c copy -copy_unknown -f data raw.bin)ffprobe -select_streams -show_packets -show_frames
2021-09-15 18:05:39 125
原创 unique_ptr
#include <memory>#include <iostream>#include <vector>typedef struct xx { int len; std::unique_ptr<char[]> data;}XX;////std::unique_ptr<char[]> chars(new char[1024]);typedef std::unique_ptr<XX> P_esdata;...
2021-09-11 15:46:57 367
转载 std:array
2. char buffer[] 与 vector<char> 互转buffer --> vector<char>vector<char> vec(buffer, buffer+sizeof(buffer)/sizeof(buffer[0]-1)); //will assign length charvec.assign(buffer, buffer+sizeof(buffer)/sizeof(buffer[0])-1); //will assign leng
2021-09-05 12:27:11 96
原创 stringstream 当作buffer 来用
https://www.apiref.com/cpp-zh/cpp/io/basic_stringstream.htmlvoid strtest2(){ char s[22] = "aabbccddeeff"; char d[22] = { 0 }; int xx; stringstream x; // std::cout << "Hello World!\n"; printf("%d \n", x.tellp()); print...
2021-09-05 11:56:12 176
原创 你要的多线程内存池 GNU 帮你写好了
#include <iostream>#include <ext/mt_allocator.h>typedef __gnu_cxx::__mt_alloc<int> allocator_type;int main(){ std::cout << "dddd"; allocator_type att; allocator_type::pointer p1 = att.allocate(128); allocator_typ...
2021-09-05 10:58:06 143
转载 链接选项Bsymbolic
问题描述回归正题,前段时间项目开发中,实现了一个动态库,封装了一些方法。然后基于这个动态库,实现了一个应用程序。应用程序中含有全局变量A,动态库中也含有全局变量A,当我调用动态库中函数后,发现应用程序的A发生了变化!!!O,My God!对于我这种还没在Linux下做过开发的人来说,一头雾水。。。。。。 于是我尝试着,将A中的变量名称改为B,这样问题也就没有了~~~原因应用程序进行链接的...
2018-11-01 09:35:48 2768
转载 gcc -Wl,--wrap,malloc 替换系统函数
GNU链接器就提供了一个好用的方法:–wrap=symbol函数名为“__wrap_symbol”,且称其为包装函数,“symbol”是一个函数名,大致执行过程是这样的:当调用“symbol”函数时,如果“symbol”函数未定义的话就会调用“__wrap_symbol”函数;“__real_symbol”也是个相关的函数,当其只声明不定义的话,我们对其的调用将调用真正的“symbol”函...
2018-10-26 14:17:27 6892
转载 kthread/waitqueue/tasklet/set_bit
•Softirq是中断下半部的处理方式(可以在不同cpu上同时运行)•tasklet是基于softirq实现的,使用比softirq简单.不能在不同cpu上同时运行,但是不同cpu可以运行不同的tasklet.•vk_tasklet_init (&pstDecObj->stDecTasklet ,pstDecObj->pfnHandleDecodeDone, (unsigned l
2018-01-16 14:27:20 584
原创 python 使用opencv 把视频 分割成图片
#--coding:utf-8--import cv2#图像路径名字错误不提示im=cv2.imread("timg.jpg",cv2.IMREAD_GRAYSCALE)cv2.imwrite('res.jpg',im)'''cap=cv2.VideoCapture("1EF5013E37956E7EF2D5F935B6107F34.mp4")while True:
2017-12-31 20:25:12 4922 1
原创 python 使用 imagehash 和 distance 相似图片识别
#--coding:utf-8--from PIL import Imageimport imagehashimport distancefunct_hash=imagehash.phashpil_im=Image.open(r"timg.jpg")stepx=64stepy=64print pil_im.sizeoneitem=[]res_box=[]'''d
2017-12-31 20:18:28 2480 1
转载 hook glibc
我们知道,Linux的用C库的都是glibc,有一个叫libc.so.6的文件,这是几乎所有Linux下命令的动态链接中,其中有标准C的各种函数,默认情况下,linux所编译的程序中对标准C函数的链接,都是通过动态链接方式来链接libc.so.6这个函数库的。这也意味着我们在通过我们注入的.so来实现函数覆盖劫持之后需要从libc.so.6中取得原本的正常函数,让程序继续正常执行正常程序m
2017-12-12 11:33:28 853
原创 记录一次 linux kernel bug
[2017-07-28 12:07:43:423][160290.942415] ------------[ cut here ]------------[2017-07-28 12:07:43:423][160290.947109] kernel BUG at fs/ext4/mballoc.c:3728![2017-07-28 12:07:43:423][160290.9518
2017-12-06 10:26:56 1458
原创 nltk_data 离线安装
windows 默认搜索路径 Searched in: - 'C:\\Users\\xa00010/nltk_data' - 'C:\\nltk_data' - 'D:\\nltk_data' - 'E:\\nltk_data' - 'C:\\Python27\\nltk_data' - 'C:\\Python27\\lib\\nl
2017-12-06 10:26:29 2442
转载 使用静态busybox 性能提升, 确一直coredump 的问题
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/arm/include/asm/processor.h?id=acfdd4b1f7590d02e9bae3b73bdbbc4a31b05d38经分析需要kernel 打patch
2017-12-06 10:26:10 319
转载 python requests 库 跳过ssl 验证
# -*- coding: utf-8 -*-import requestsimport sysreload(sys)sys.setdefaultencoding('utf-8')#import ssl#ssl._create_default_https_context = ssl._create_unverified_contextproxy_handler = {'http':
2017-12-06 09:37:50 8005
转载 使用valgrind 检查内存 泄露 等问题
export VALGRIND_LIB=/data/build.so/lib/valgrind/cd /data/build.so/bin./valgrind --tool=massif--threshold=0.000001 --time-unit=B --trace-children=yes --time-unit=B--trace-children-skip=*pangu,SCLR*
2017-12-05 11:26:36 187
原创 记录一次系统调用慢的 分析过程
收到问题jira描述• • [EM] 0131559] [工厂适应性问题]执行shell命令,系统反应慢• 分析发现调用系统system函数执行命令的时间过长,每条命令执行约250ms。对比其它平台只需要
2017-12-05 11:21:19 4243
转载 使用facebook infer 进行代码审查
http://fbinfer.com/docs/getting-started.htmlhttp://fbinfer.com/docs/hello-world.html
2017-12-05 11:10:21 425
转载 使用trace-compass 分析 lttng 抓取的结果
2. http://archive.eclipse.org/tracecompass/doc/org.eclipse.tracecompass.doc.user/Trace-Compass-Main-Features.html 此工具可以直接下载3. trace-compass-3.0.0-20170614-1849-win32.win32.x86_64
2017-12-05 11:06:50 2694
原创 观察中断情况, 绑定 指定的cpu
void* threadfunction (){cpu_set_t mask;CPU_ZERO(&mask);CPU_SET(0,&mask); 第一个参数是你要绑定的cpu if(-1 == pthread_setaffinity_np(pthread_self() ,sizeof(mask),&mask)) { fprintf(stderr, "pthread_
2017-12-05 10:55:06 429
原创 进程 线程 优先级调整方法
1. nice 优先级的范围为-20~ 19 等40个等级,其中数值越小优先级越高,数值越大优先级越低,既-20的优先级最高, 19的优先级最低2. chrt 命令chrt -p -r 50 调整成RR 50 chrt -p 是查询 chrt -p -o 0 调整成other
2017-12-05 10:51:15 1403
原创 记录一次 busybox 死机
(gdb) bt#0 0x0009be32 in ____strtoll_l_internal ()#1 0x0009b7b4 in strtoq ()#2 0x0006c3d2 in mdev_main(argc=, argv=) atutil-linux/mdev.c:1116#3 0x0002f18c in run_applet_no_and_exit(applet_
2017-12-05 10:34:40 680
原创 使用cgroup 分配 cpu 资源给各个进程
mkdir /cgroupmount -t cgroup -o cpu cgroup /cgroupmkdir /cgroup/GroupAmkdir /cgroup/GroupBfor iii in `pidof sitatvservice`do echo $iii > /cgroup/GroupA/tasksdonefor iii in `pidof appman
2017-12-05 10:31:28 977
原创 使用 mmap64 和 /dev/mem 访问物理内存
static int _STBC_function_open(void){ //int fd; fdmem = open("/dev/mem", O_RDWR|O_SYNC); if (fdmem == -1) { printf("open dev mem error \n"); return (-1); } #define KER_STBC_REG_BA
2017-12-05 10:17:48 7440
原创 python 多线程爬取考拉商品评论
#--coding:utf-8--+from multiprocessing.dummy import Pool as ThreadPoolimport requestsimport multiprocessingimport jsonimport timedef commentslistbyindex(id): payload={"goodsId":"1351082",
2017-12-03 22:31:34 545
原创 python Beautiful Soup lxml 兼容性好
from bs4 import BeautifulSoupdef commentslistbyindex(index): ss=requests.get("http://www.aigaogao.com/tools/history.html?s=300357").content soup = BeautifulSoup(ss,"lxml") tables = sou
2017-12-03 13:08:57 210
原创 python 多进程模块 multiprocessing
if __name__ == '__main__': # 所有多进程操作要写在这个if 下. 进程关系决定的 multiprocessing.freeze_support() #此句windows 上必须 print time.asctime( time.localtime(time.time()) ) pool=multiprocessing.Pool()
2017-12-02 23:49:36 271 1
原创 poll 系统调用timeout 不返回
TIME_OUT_THIRTY_MILLI 30status = poll((struct pollfd*)&poll_events, ONE, TIME_OUT_THIRTY_MILLI);[ 53.080533] NdVideoDec_0 [0] S [d5221f80] c04b6b7c 0 1918 0x00000000 1 (user thread)[ 53
2017-11-30 14:12:35 4490
原创 动态库的符号隐藏
overview• gcc -fPIC -c a.c• gcc -fPIC -c b.c• gcc -fPIC -c c.c• gcc -fPIC -c d.c• gcc -shared -o libfoo2.so a.o b.o -Wl,--version-script=libfoo.map• gc
2017-11-28 13:29:27 2749
转载 sanitizers
https://github.com/google/sanitizersThis project is the home for Sanitizers: AddressSanitizer, MemorySanitizer, ThreadSanitizer, LeakSanitizer. The actual code resides in the LLVM reposi
2017-11-28 10:44:50 1317
原创 nuttx os porting
Nuttxporting step co-work other member1.Nuttx OS porting 相关的目录介绍. |- nuttx| |-- Makefile| |-- Kconfig| |-- Documentation| | `-- (documentation files)/| |-- arch/|
2017-11-28 10:41:37 647
转载 使用objcopy 弱化符号 和 替换 符号
之前文章讲过 使用 ld_preload 来实现函数替换 $ arm--linux-gnu-ar x libc.a malloc.o$ arm-linux-gnu-objcopy -W malloc malloc.o$ arm--linux-gnu-objcopy -W realloc malloc.o$ arm--linux-gnu-objcopy -W free malloc.o$ arm--...
2017-11-28 10:17:51 1500
原创 堆栈被破坏 gdb 无法回溯调用栈 怎么办?
我们有事会遇到 gdb 查看 corefile 文件 ,无法打印 backtrace 的问题. 此处以arm 为例 User Stack: (0xa5a32d38 to 0xa5a32d38 + 栈大小)sp 指针就是 0xa5a32d38 线程堆栈大小一般是固定的 pmap -x pid be6b5000 132 1
2017-11-23 11:35:03 3199
原创 使用LD_PRELOAD 加系统调用 替换libc原有函数
环境变量 LD_PRELOAD 路径下的 so 会优先加载这里以替换mmap 函数作为示例 #include #include #include #define gettidv1() syscall(__NR_gettid) //#define __NR_mmap2 (__NR_SYSCALL_BASE+192)//arm-linux-gnueabihf/libc/us
2017-11-22 09:40:54 2117
原创 top -m 观察内存变化趋势 嵌入式适用 oom
公司TV 有一项重要指标就是 压力测试top -m -d 10 -b> top.logtop m 参数可以很好的观察各个进程再压力测试过程中的变化 oom
2017-11-21 16:12:52 3890
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人