시스템에서 생성 된 모든 코어 파일을 특정 응용 프로그램의 특정 빈 버전에 바인딩해야합니다. sysctl.conf : kernel.core_pattern에 core-name 패턴을 지정할 수 있지만 여기에 bin 버전을 넣을 방법이 없습니다.코어 덤프 : 충돌 한 응용 프로그램의 버전을 확인하는 방법
크래시 된 프로그램의 버전을 코어 파일 (리비전 번호) 또는 다른 방법으로 충돌이 발생한 프로그램의 버전을 확인할 수있는 방법은 무엇입니까?
시스템에서 생성 된 모든 코어 파일을 특정 응용 프로그램의 특정 빈 버전에 바인딩해야합니다. sysctl.conf : kernel.core_pattern에 core-name 패턴을 지정할 수 있지만 여기에 bin 버전을 넣을 방법이 없습니다.코어 덤프 : 충돌 한 응용 프로그램의 버전을 확인하는 방법
크래시 된 프로그램의 버전을 코어 파일 (리비전 번호) 또는 다른 방법으로 충돌이 발생한 프로그램의 버전을 확인할 수있는 방법은 무엇입니까?
SVN의 수정 번호가 들어있는 .pro 파일에서 qmake VERSION 변수를 사용하고 있습니다. 그것 QCoreApplication :: applicationVersion()에 의해 사용할 수있는, 내 모든 빈 플래그 - 버전.
코어 덤프없이 버전 번호를 출력 할 수 있다고 가정하면 코어 덤프가 호출하는 작은 프로그램 (파이썬은 아마도 가장 쉽다)을 작성할 수 있습니다. 프로그램은 stdin을 읽고 파일에 덤프 한 다음 버전 번호를 기반으로 파일의 이름을 바꿉니다. 사람 (5) 핵심에서
:
Piping core dumps to a program Since kernel 2.6.19, Linux supports an alternate syntax for the /proc/sys/kernel/core_pattern file. If the first character of this file is a pipe symbol (|), then the remainder of the line is inter‐ preted as a program to be executed. Instead of being written to a disk file, the core dump is given as standard input to the program. Note the following points: * The program must be specified using an absolute pathname (or a path‐ name relative to the root directory, /), and must immediately follow the '|' character. * The process created to run the program runs as user and group root. * Command-line arguments can be supplied to the program (since Linux 2.6.24), delimited by white space (up to a total line length of 128 bytes). * The command-line arguments can include any of the % specifiers listed above. For example, to pass the PID of the process that is being dumped, specify %p in an argument.
당신은 다음
echo "| /usr/local/bin/dumper %E" > /proc/sys/kernel/core_pattern
스크립트/usr/지방/빈/덤퍼, 덤퍼가 시도 후, 파일에 표준 입력 복사해야을 호출하는 경우 명령 행에서 이름이 지정된 프로그램을 실행하여 버전 번호를 추출하고이를 사용하여 파일의 이름을 바꿉니다. 이 같은
뭔가 내가 그것을 시도하지 않은 (작동, 그래서 극단적 인 위험 :)에 사용할 수
#!/usr/bin/python
import sys,os,subprocess
from subprocess import check_output
CORE_FNAME="/tmp/core"
with open(CORE_FNAME,"f") as f:
while buf=sys.stdin.read(10000):
f.write(buf)
pname=sys.argv[1].replace('!','/')
out=subprocess.check_output([pname, "--version"])
version=out.split('\n')[0].split()[-1]
os.rename(CORE_FNAME, CORE_FNAME+version)
이 시스템을 충돌 할 수 있습니다 재귀 코어 덤프입니다 수행의 정말 큰 위험. 코어 덤프없이 자체 버전을 인쇄 할 수있는 프로세스에서만 코어 덤프를 허용하려면 ulimit을 사용해야합니다.
기대하는 프로그램 인 경우 프로그램을 다시 실행하여 버전 정보를 얻으려면 스크립트를 변경하는 것이 좋습니다.
정확히 bin 버전입니까? 버전 번호를 얻기 위해 추출해야하는 실행 파일의 어딘가에 어떤 변수를 유지합니까? – evaitl
SVN의 개정 번호가 들어있는 .pro 파일에서 qmake VERSION 변수를 사용하고 있습니다. 그것 QCoreApplication :: applicationVersion()에 의해 사용할 수있는, 내 모든 빈 플래그 - 버전. – portinary