2016-11-25 17:18:40 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Jehanne.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015-2016 Giacomo Tesio <giacomo@tesio.it>
|
|
|
|
*
|
|
|
|
* Jehanne is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 2 of the License.
|
|
|
|
*
|
|
|
|
* Jehanne is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#include "u.h"
|
|
|
|
#include "../port/lib.h"
|
|
|
|
#include "mem.h"
|
|
|
|
#include "dat.h"
|
|
|
|
#include "fns.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print functions for system call tracing.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
fmtrwdata(Fmt* f, char* a, int n)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char *t;
|
|
|
|
|
|
|
|
if(a == nil){
|
2017-04-19 23:33:14 +02:00
|
|
|
jehanne_fmtprint(f, " 0x0%s");
|
2016-11-25 17:18:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
a = validaddr(a, n, 0);
|
|
|
|
t = smalloc(n+1);
|
|
|
|
for(i = 0; i < n; i++){
|
|
|
|
if(a[i] > 0x20 && a[i] < 0x7f)
|
|
|
|
t[i] = a[i];
|
|
|
|
else
|
|
|
|
t[i] = '.';
|
|
|
|
}
|
|
|
|
t[n] = 0;
|
|
|
|
|
2017-04-19 23:33:14 +02:00
|
|
|
jehanne_fmtprint(f, " %#p/\"%s\"", a, t);
|
|
|
|
jehanne_free(t);
|
2016-11-25 17:18:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
fmtuserstring(Fmt* f, const char* a)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
char *t;
|
|
|
|
|
|
|
|
if(a == nil){
|
2017-04-19 23:33:14 +02:00
|
|
|
jehanne_fmtprint(f, " 0/\"\"");
|
2016-11-25 17:18:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
a = validaddr((void*)a, 1, 0);
|
|
|
|
n = ((char*)vmemchr((char*)a, 0, 0x7fffffff) - a) + 1;
|
|
|
|
t = smalloc(n+1);
|
2017-04-19 23:33:14 +02:00
|
|
|
jehanne_memmove(t, (char*)a, n);
|
2016-11-25 17:18:40 +01:00
|
|
|
t[n] = 0;
|
2017-04-19 23:33:14 +02:00
|
|
|
jehanne_fmtprint(f, " %#p/\"%s\"", a, t);
|
|
|
|
jehanne_free(t);
|
2016-11-25 17:18:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
fmtuserstringlist(Fmt* fmt, const char** argv)
|
|
|
|
{
|
|
|
|
char* a;
|
|
|
|
evenaddr(PTR2UINT(argv));
|
|
|
|
for(;;){
|
|
|
|
a = *(char**)validaddr((char**)argv, sizeof(char**), 0);
|
|
|
|
if(a == nil)
|
|
|
|
break;
|
2017-04-19 23:33:14 +02:00
|
|
|
jehanne_fmtprint(fmt, " ");
|
2016-11-25 17:18:40 +01:00
|
|
|
fmtuserstring(fmt, a);
|
|
|
|
argv++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|