[131335]: nouveau-pm / tools / extract.c Maximize Restore History

Download this file

extract.c    84 lines (74 with data), 2.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#
# This is a small program that splits the dumps into sections
# correcponding to the different periods in the downclocking
# The file info.txt shows the frequencies, and the dumps that
# contain information about it
#
# XXX: Take the input name from the command line
# XXX: Simplify this using a script?
#include <stdio.h>
#include <string.h>
int main(void)
{
FILE *srcFile, *outputFile, *infoFile;
char mark_str[100], *nv_str, outputfile_name[255];
char *data, buffer[100], *ret, *nv_available, *perf_list_available;
int counter, start, is_mark;
counter = start = is_mark = 0;
srcFile = fopen("mydump.txt","r");
if ( srcFile == NULL)
{
printf("Cannot open file\n");
return(1);
}
infoFile = fopen("info.txt","w");
if ( infoFile == NULL)
{
printf("Cannot info create file\n");
fclose(srcFile);
return(1);
}
ret = fgets(buffer, 100, srcFile);
outputFile = NULL;
while (( ret != NULL ) && ( !feof(srcFile) ))
{
sscanf( buffer , "%s", mark_str);
is_mark = strncmp(mark_str,"MARK",4);
nv_str = strstr( buffer, "NV_" );
if (( is_mark != 0 ) && ( start == 1 ))
{
fputs( buffer, outputFile);
}
if ((is_mark == 0) && ( nv_str != NULL ))
{
perf_list_available = strstr( buffer, "NV_CTRL_STRING_PERFORMANCE_MODES");
if ( perf_list_available != NULL)
fprintf( infoFile,"%s", perf_list_available );
nv_available = strstr( buffer, "NV_CTRL_GPU_CURRENT_CLOCK_FREQS");
if ( nv_available != NULL)
{
fprintf( infoFile,"%s >>>>>> %i.txt <<<<<<\n", nv_available, counter+1 );
if (outputFile != NULL )
{
fclose(outputFile);
}
counter++;
sprintf( outputfile_name, "%d.txt", counter );
outputFile = fopen(outputfile_name,"w");
if ( outputFile == NULL)
{
printf("Cannot create file\n");
fclose(srcFile);
fclose(infoFile);
return(1);
}
start = 1;
}
}
ret = fgets(buffer, 200, srcFile);
}
if (outputFile != NULL) fclose(outputFile);
if (infoFile != NULL) fclose(infoFile);
if (srcFile != NULL) fclose(srcFile);
return 0;
}