Skip to content

Commit

Permalink
feat: Connected stack and functions with server.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubh942 committed Aug 8, 2024
1 parent 3fc45a3 commit 9301a03
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 29 deletions.
60 changes: 42 additions & 18 deletions webapp/src/components/Functions/Functions.jsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,53 @@
import React from "react";
import React, { useEffect } from "react";
import { DataState } from "./../../context/DataContext";
import "./Functions.css";
import axios from "axios";

const data = [
"sub.KERNEL32.dll_DeleteCritical_231",
"sub.KERNEL32.dll_DeleteCritical_231",
"sub.KERNEL32.dll_DeleteCritical_231",
"sub.KERNEL32.dll_DeleteCritical_231",
"sub.KERNEL32.dll_DeleteCritical_231",
"sub.KERNEL32.dll_DeleteCritical_231",
"sub.KERNEL32.dll_DeleteCritical_231",
"sub.KERNEL32.dll_DeleteCritical_231",
"sub.KERNEL32.dll_DeleteCritical_231",
"sub.KERNEL32.dll_DeleteCritical_231",
];

const Functions = () => {
const { refresh, functions, setFunctions } = DataState();

Check failure on line 20 in webapp/src/components/Functions/Functions.jsx

View workflow job for this annotation

GitHub Actions / test-npm

src/components/Functions/__tests__/Functions.test.jsx > renders Functions component with correct heading and function names

TypeError: Cannot destructure property 'refresh' of 'DataState(...)' as it is undefined. ❯ Functions src/components/Functions/Functions.jsx:20:11 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 node_modules/react-dom/cjs/react-dom.development.js:27465:14 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom.development.js:26599:12 ❯ workLoopSync node_modules/react-dom/cjs/react-dom.development.js:26505:5 ❯ renderRootSync node_modules/react-dom/cjs/react-dom.development.js:26473:7 ❯ recoverFromConcurrentError node_modules/react-dom/cjs/react-dom.development.js:25889:20 ❯ performConcurrentWorkOnRoot node_modules/react-dom/cjs/react-dom.development.js:25789:22

const fetchFunctionsData = async () => {
try {
console.log("click from functions");
const data = await axios.post("http://127.0.0.1:10000/get_locals", {
name: "program",
});
console.log(data.data.result);
setFunctions(data.data.result);
} catch (error) {
console.log(error);
}
};

useEffect(() => {
if (refresh) {
fetchFunctionsData();
}
}, [refresh]);

return (
<div className="functions-parent">
<a className="functions-heading"> Functions</a>
offset
<div className="functions">
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
<a>sub.KERNEL32.dll_DeleteCritical_231</a>
{functions}
{data.map((obj) => {
return <a>{obj}</a>;
})}
{/* <a>sub.KERNEL32.dll_DeleteCritical_231</a> */}
</div>
</div>
);
Expand Down
26 changes: 21 additions & 5 deletions webapp/src/components/Stack/Stack.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
import React from "react";
import React, { useEffect } from "react";
import { DataState } from "./../../context/DataContext";
import "./Stack.css";
import axios from "axios";

const Stack = () => {
const { refresh, stack, setStack } = DataState();

Check failure on line 7 in webapp/src/components/Stack/Stack.jsx

View workflow job for this annotation

GitHub Actions / test-npm

src/components/Stack/__tests__/Stack.test.jsx > renders Stack component with stack items

TypeError: Cannot destructure property 'refresh' of 'DataState(...)' as it is undefined. ❯ Stack src/components/Stack/Stack.jsx:7:11 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 node_modules/react-dom/cjs/react-dom.development.js:27465:14 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom.development.js:26599:12 ❯ workLoopSync node_modules/react-dom/cjs/react-dom.development.js:26505:5 ❯ renderRootSync node_modules/react-dom/cjs/react-dom.development.js:26473:7 ❯ recoverFromConcurrentError node_modules/react-dom/cjs/react-dom.development.js:25889:20 ❯ performConcurrentWorkOnRoot node_modules/react-dom/cjs/react-dom.development.js:25789:22

const fetStackData = async () => {
try {
console.log("click from stack");
const data = await axios.post("http://127.0.0.1:10000/stack_trace", {
name: "program",
});
console.log(data.data.result);
setStack(data.data.result);
} catch (error) {
console.log(error);
}
};
useEffect(() => {
if (refresh) fetStackData();
}, [refresh]);
return (
<div className="stack-parent">
<div className="stack-heading">Stack</div>
Offset
<div className="stack">
<div>0x001780c8 0x001780c8 0x001780c8 0x001780c8</div>
<div>0x001780c8 0x001780c8 0x001780c8 0x001780c8</div>
<div>0x001780c8 0x001780c8 0x001780c8 0x001780c8</div>
<div>0x001780c8 0x001780c8 0x001780c8 0x001780c8</div>
<div>{stack}</div>
<div>0x001780c8 0x001780c8 0x001780c8 0x001780c8</div>
<div>0x001780c8 0x001780c8 0x001780c8 0x001780c8</div>
<div>0x001780c8 0x001780c8 0x001780c8 0x001780c8</div>
Expand Down
8 changes: 2 additions & 6 deletions webapp/src/context/DataContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ export const DataProvider = ({ children }) => {
const fetchData = useCallback(async () => {
if (refresh) {
try {
const stackResponse = await axios.get("/api/stack");
const functionsResponse = await axios.get("/api/functions");

setStack(stackResponse.data);
setFunctions(functionsResponse.data);

setRefresh(false);
} catch (error) {
console.error("Error fetching data:", error);
Expand All @@ -43,7 +37,9 @@ export const DataProvider = ({ children }) => {
refresh,
setRefresh,
stack,
setStack,
functions,
setFunctions,
infoBreakpointData,
setInfoBreakpointData,
memoryMap,
Expand Down

0 comments on commit 9301a03

Please sign in to comment.